<!doctype html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>MEME ChIP</title>
    <script>
      // @JSON_VAR data
      var data = {
        "filter_thresh": "0.05",
        "version": "5.0.2",
        "revision": "a40a52a93b6dce029c34699a737ea432925cfe33",
        "release": "Thu Aug 30 14:26:08 2018 -0700",
        "cmd": [
          "meme-chip", "-oc", "meme/meme-chip_TCP7_1", "-dna", "-meme-brief",
          "200000", "-meme-nmotifs", "5", "-meme-minw", "6", "-meme-maxw",
          "16", "-meme-p", "2", "-dreme-m", "5", "meme/TCP7_1.meme.fa"
        ],
        "programs": [
          {
            "name": "count_seqs",
            "cmd": "getsize meme/meme-chip_TCP7_1/TCP7_1.meme.fa 1> $metrics",
            "status": 0,
            "oot": false,
            "time": 0.041411,
            "outputs": []
          }, {
            "name": "most_seqs",
            "cmd": "fasta-most -min 50 < meme/meme-chip_TCP7_1/TCP7_1.meme.fa 1> $metrics",
            "status": 0,
            "oot": false,
            "time": 0.044429,
            "outputs": []
          }, {
            "name": "center_seqs",
            "cmd": "fasta-center -dna -len 100 < meme/meme-chip_TCP7_1/TCP7_1.meme.fa 1> meme/meme-chip_TCP7_1/seqs-centered",
            "status": 0,
            "oot": false,
            "time": 0.060494,
            "outputs": [
              {
                "name": "seqs-centered",
                "file": "seqs-centered"
              }
            ]
          }, {
            "name": "shuffle_seqs",
            "cmd": "fasta-shuffle-letters meme/meme-chip_TCP7_1/seqs-centered meme/meme-chip_TCP7_1/seqs-shuffled -kmer 2 -tag -dinuc -dna -seed 1",
            "status": 0,
            "oot": false,
            "time": 0.022224,
            "outputs": [
              {
                "name": "seqs-shuffled",
                "file": "seqs-shuffled"
              }
            ]
          }, {
            "name": "bg",
            "cmd": "fasta-get-markov -nostatus -nosummary -dna -m 1 meme/meme-chip_TCP7_1/TCP7_1.meme.fa meme/meme-chip_TCP7_1/background",
            "status": 0,
            "oot": false,
            "time": 0.016094,
            "outputs": [
              {
                "name": "Background",
                "file": "background"
              }
            ]
          }, {
            "name": "meme",
            "cmd": "meme meme/meme-chip_TCP7_1/seqs-centered -oc meme/meme-chip_TCP7_1/meme_out -mod zoops -nmotifs 5 -minw 6 -maxw 16 -bfile meme/meme-chip_TCP7_1/background -dna -p 2 -revcomp -brief 200000 -nostatus",
            "status": 0,
            "oot": false,
            "time": 1596.121269,
            "outputs": [
              {
                "name": "MEME HTML",
                "file": "meme_out/meme.html"
              }, {
                "name": "MEME text",
                "file": "meme_out/meme.txt"
              }, {
                "name": "MEME XML",
                "file": "meme_out/meme.xml"
              }
            ]
          }, {
            "name": "dreme",
            "cmd": "dreme-py3 -verbosity 1 -oc meme/meme-chip_TCP7_1/dreme_out -png -dna -p meme/meme-chip_TCP7_1/seqs-centered -n meme/meme-chip_TCP7_1/seqs-shuffled -m 5",
            "status": 0,
            "oot": false,
            "time": 95.021019,
            "messages_file": "dreme_msgs.txt",
            "outputs": [
              {
                "name": "DREME HTML",
                "file": "dreme_out/dreme.html"
              }, {
                "name": "DREME text",
                "file": "dreme_out/dreme.txt"
              }, {
                "name": "DREME XML",
                "file": "dreme_out/dreme.xml"
              }
            ]
          }, {
            "name": "centrimo",
            "cmd": "centrimo -seqlen 300 -verbosity 1 -oc meme/meme-chip_TCP7_1/centrimo_out -bfile meme/meme-chip_TCP7_1/background meme/meme-chip_TCP7_1/TCP7_1.meme.fa meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/dreme_out/dreme.xml",
            "status": 0,
            "oot": false,
            "time": 1.223064,
            "outputs": [
              {
                "name": "CentriMo HTML",
                "file": "centrimo_out/centrimo.html"
              }, {
                "name": "Site Counts",
                "file": "centrimo_out/site_counts.txt"
              }
            ]
          }, {
            "name": "align",
            "cmd": "tomtom -verbosity 1 -text -thresh 0.1 meme/meme-chip_TCP7_1/combined.meme meme/meme-chip_TCP7_1/combined.meme 1> meme/meme-chip_TCP7_1/motif_alignment.txt",
            "status": 0,
            "oot": false,
            "time": 0.142049,
            "outputs": [
              {
                "name": "Motif Alignment",
                "file": "motif_alignment.txt"
              }
            ]
          }, {
            "name": "spamo1",
            "cmd": "spamo -verbosity 1 -oc meme/meme-chip_TCP7_1/spamo_out_1 -bgfile meme/meme-chip_TCP7_1/background -keepprimary -primary TGSRRGTGGGCCCCRC meme/meme-chip_TCP7_1/TCP7_1.meme.fa meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/dreme_out/dreme.xml",
            "status": 0,
            "oot": false,
            "time": 1.922605,
            "messages_file": "spamo1_msgs.txt",
            "outputs": [
              {
                "name": "SpaMo HTML",
                "file": "spamo_out_1/spamo.html"
              }
            ]
          }, {
            "name": "spamo2",
            "cmd": "spamo -verbosity 1 -oc meme/meme-chip_TCP7_1/spamo_out_2 -bgfile meme/meme-chip_TCP7_1/background -keepprimary -primary CTGAAACCCGRAGTAA meme/meme-chip_TCP7_1/TCP7_1.meme.fa meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/dreme_out/dreme.xml",
            "status": 0,
            "oot": false,
            "time": 1.93557,
            "messages_file": "spamo2_msgs.txt",
            "outputs": [
              {
                "name": "SpaMo HTML",
                "file": "spamo_out_2/spamo.html"
              }
            ]
          }, {
            "name": "spamo3",
            "cmd": "spamo -verbosity 1 -oc meme/meme-chip_TCP7_1/spamo_out_3 -bgfile meme/meme-chip_TCP7_1/background -keepprimary -primary CCCACCCCGAATTTC meme/meme-chip_TCP7_1/TCP7_1.meme.fa meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/dreme_out/dreme.xml",
            "status": 0,
            "oot": false,
            "time": 2.002164,
            "messages_file": "spamo3_msgs.txt",
            "outputs": [
              {
                "name": "SpaMo HTML",
                "file": "spamo_out_3/spamo.html"
              }
            ]
          }, {
            "name": "spamo4",
            "cmd": "spamo -verbosity 1 -oc meme/meme-chip_TCP7_1/spamo_out_4 -bgfile meme/meme-chip_TCP7_1/background -keepprimary -primary TTTTCGGTAAATTTT meme/meme-chip_TCP7_1/TCP7_1.meme.fa meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/dreme_out/dreme.xml",
            "status": 0,
            "oot": false,
            "time": 1.93932,
            "messages_file": "spamo4_msgs.txt",
            "outputs": [
              {
                "name": "SpaMo HTML",
                "file": "spamo_out_4/spamo.html"
              }
            ]
          }, {
            "name": "spamo5",
            "cmd": "spamo -verbosity 1 -oc meme/meme-chip_TCP7_1/spamo_out_5 -bgfile meme/meme-chip_TCP7_1/background -keepprimary -primary TYGGCATAACCTCCCT meme/meme-chip_TCP7_1/TCP7_1.meme.fa meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/dreme_out/dreme.xml",
            "status": 0,
            "oot": false,
            "time": 1.91894,
            "messages_file": "spamo5_msgs.txt",
            "outputs": [
              {
                "name": "SpaMo HTML",
                "file": "spamo_out_5/spamo.html"
              }
            ]
          }, {
            "name": "spamo6",
            "cmd": "spamo -verbosity 1 -oc meme/meme-chip_TCP7_1/spamo_out_6 -bgfile meme/meme-chip_TCP7_1/background -keepprimary -primary GAYTTACY meme/meme-chip_TCP7_1/TCP7_1.meme.fa meme/meme-chip_TCP7_1/dreme_out/dreme.xml meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/dreme_out/dreme.xml",
            "status": 0,
            "oot": false,
            "time": 1.01297,
            "messages_file": "spamo6_msgs.txt",
            "outputs": [
              {
                "name": "SpaMo HTML",
                "file": "spamo_out_6/spamo.html"
              }
            ]
          }, {
            "name": "fimo1",
            "cmd": "fimo --parse-genomic-coord --verbosity 1 --oc meme/meme-chip_TCP7_1/fimo_out_1 --bgfile meme/meme-chip_TCP7_1/background --motif TGSRRGTGGGCCCCRC meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/TCP7_1.meme.fa",
            "status": 0,
            "oot": false,
            "time": 1.040592,
            "outputs": [
              {
                "name": "FIMO GFF",
                "file": "fimo_out_1/fimo.gff"
              }, {
                "name": "FIMO HTML",
                "file": "fimo_out_1/fimo.html"
              }, {
                "name": "FIMO TSV",
                "file": "fimo_out_1/fimo.tsv"
              }
            ]
          }, {
            "name": "fimo2",
            "cmd": "fimo --parse-genomic-coord --verbosity 1 --oc meme/meme-chip_TCP7_1/fimo_out_2 --bgfile meme/meme-chip_TCP7_1/background --motif CTGAAACCCGRAGTAA meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/TCP7_1.meme.fa",
            "status": 0,
            "oot": false,
            "time": 1.021487,
            "outputs": [
              {
                "name": "FIMO GFF",
                "file": "fimo_out_2/fimo.gff"
              }, {
                "name": "FIMO HTML",
                "file": "fimo_out_2/fimo.html"
              }, {
                "name": "FIMO TSV",
                "file": "fimo_out_2/fimo.tsv"
              }
            ]
          }, {
            "name": "fimo3",
            "cmd": "fimo --parse-genomic-coord --verbosity 1 --oc meme/meme-chip_TCP7_1/fimo_out_3 --bgfile meme/meme-chip_TCP7_1/background --motif CCCACCCCGAATTTC meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/TCP7_1.meme.fa",
            "status": 0,
            "oot": false,
            "time": 1.015881,
            "outputs": [
              {
                "name": "FIMO GFF",
                "file": "fimo_out_3/fimo.gff"
              }, {
                "name": "FIMO HTML",
                "file": "fimo_out_3/fimo.html"
              }, {
                "name": "FIMO TSV",
                "file": "fimo_out_3/fimo.tsv"
              }
            ]
          }, {
            "name": "fimo4",
            "cmd": "fimo --parse-genomic-coord --verbosity 1 --oc meme/meme-chip_TCP7_1/fimo_out_4 --bgfile meme/meme-chip_TCP7_1/background --motif TTTTCGGTAAATTTT meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/TCP7_1.meme.fa",
            "status": 0,
            "oot": false,
            "time": 1.016319,
            "outputs": [
              {
                "name": "FIMO GFF",
                "file": "fimo_out_4/fimo.gff"
              }, {
                "name": "FIMO HTML",
                "file": "fimo_out_4/fimo.html"
              }, {
                "name": "FIMO TSV",
                "file": "fimo_out_4/fimo.tsv"
              }
            ]
          }, {
            "name": "fimo5",
            "cmd": "fimo --parse-genomic-coord --verbosity 1 --oc meme/meme-chip_TCP7_1/fimo_out_5 --bgfile meme/meme-chip_TCP7_1/background --motif TYGGCATAACCTCCCT meme/meme-chip_TCP7_1/meme_out/meme.xml meme/meme-chip_TCP7_1/TCP7_1.meme.fa",
            "status": 0,
            "oot": false,
            "time": 1.020317,
            "outputs": [
              {
                "name": "FIMO GFF",
                "file": "fimo_out_5/fimo.gff"
              }, {
                "name": "FIMO HTML",
                "file": "fimo_out_5/fimo.html"
              }, {
                "name": "FIMO TSV",
                "file": "fimo_out_5/fimo.tsv"
              }
            ]
          }, {
            "name": "fimo6",
            "cmd": "fimo --parse-genomic-coord --verbosity 1 --oc meme/meme-chip_TCP7_1/fimo_out_6 --bgfile meme/meme-chip_TCP7_1/background --motif GAYTTACY meme/meme-chip_TCP7_1/dreme_out/dreme.xml meme/meme-chip_TCP7_1/TCP7_1.meme.fa",
            "status": 0,
            "oot": false,
            "time": 0.30983,
            "outputs": [
              {
                "name": "FIMO GFF",
                "file": "fimo_out_6/fimo.gff"
              }, {
                "name": "FIMO HTML",
                "file": "fimo_out_6/fimo.html"
              }, {
                "name": "FIMO TSV",
                "file": "fimo_out_6/fimo.tsv"
              }
            ]
          }
        ],
        "alphabet": {
          "name": "DNA",
          "like": "dna",
          "ncore": 4,
          "symbols": [
            {
              "symbol": "A",
              "name": "Adenine",
              "colour": "CC0000",
              "complement": "T"
            }, {
              "symbol": "C",
              "name": "Cytosine",
              "colour": "0000CC",
              "complement": "G"
            }, {
              "symbol": "G",
              "name": "Guanine",
              "colour": "FFB300",
              "complement": "C"
            }, {
              "symbol": "T",
              "aliases": "U",
              "name": "Thymine",
              "colour": "008000",
              "complement": "A"
            }, {
              "symbol": "N",
              "aliases": "X.",
              "name": "Any base",
              "equals": "ACGT"
            }, {
              "symbol": "V",
              "name": "Not T",
              "equals": "ACG"
            }, {
              "symbol": "H",
              "name": "Not G",
              "equals": "ACT"
            }, {
              "symbol": "D",
              "name": "Not C",
              "equals": "AGT"
            }, {
              "symbol": "B",
              "name": "Not A",
              "equals": "CGT"
            }, {
              "symbol": "M",
              "name": "Amino",
              "equals": "AC"
            }, {
              "symbol": "R",
              "name": "Purine",
              "equals": "AG"
            }, {
              "symbol": "W",
              "name": "Weak",
              "equals": "AT"
            }, {
              "symbol": "S",
              "name": "Strong",
              "equals": "CG"
            }, {
              "symbol": "Y",
              "name": "Pyrimidine",
              "equals": "CT"
            }, {
              "symbol": "K",
              "name": "Keto",
              "equals": "GT"
            }
          ]
        },
        "background": {
          "source": "--sequences--",
          "freqs": [0.2772, 0.2228, 0.2228, 0.2772]
        },
        "sequence_db": {
          "source": "meme/TCP7_1.meme.fa",
          "count": 3000,
          "file": "TCP7_1.meme.fa",
          "centrimo_seqlen": 300
        },
        "motif_dbs": [],
        "motif_count": {
          "meme": 5,
          "dreme": 5
        },
        "motifs": [
          {
            "prog": "meme",
            "db": -1,
            "id": "TGSRRGTGGGCCCCRC",
            "alt": "MEME-1",
            "consensus": "TGSRRGTGGGCCCCRC",
            "len": 16,
            "evalue": "6.0e-3027",
            "sites": 2826,
            "sig": "6.0e-3027",
            "pwm": [
              [0.106511, 0.082095, 0.262916, 0.548478], 
              [0.187898, 0.075018, 0.556971, 0.180113], 
              [0.159943, 0.258669, 0.457891, 0.123496], 
              [0.555909, 0.070418, 0.278485, 0.095188], 
              [0.294055, 0.059448, 0.492569, 0.153928], 
              [0.075372, 0.033263, 0.870134, 0.021231], 
              [0.000000, 0.030432, 0.018754, 0.950814], 
              [0.009908, 0.000000, 0.990092, 0.000000], 
              [0.000000, 0.000000, 1.000000, 0.000000], 
              [0.132343, 0.003539, 0.616419, 0.247700], 
              [0.082449, 0.672682, 0.059448, 0.185421], 
              [0.000000, 0.993984, 0.000000, 0.006016], 
              [0.000000, 1.000000, 0.000000, 0.000000], 
              [0.000000, 0.981599, 0.000000, 0.018401], 
              [0.516631, 0.021231, 0.429229, 0.032909], 
              [0.018047, 0.886412, 0.026185, 0.069356]
            ],
            "tomtom_matches": [],
            "centrimo_total_sites": 2914,
            "centrimo_sites": [
              0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 1, 0, 2, 1, 0, 0, 1, 0.5, 0,
              0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 4, 0, 0, 2, 0, 3, 3.5, 1, 1, 2,
              0, 3, 3, 3, 2, 3, 1, 3, 3, 1, 1, 1, 2, 1, 0, 0, 3, 2, 1, 3, 4.5,
              1, 1, 2, 2, 1, 3, 2, 5, 2.5, 2, 2, 5, 5, 4.5, 5, 9, 9, 7, 10.5,
              11, 6.5, 16, 12, 11, 22, 33, 27, 30, 42.5, 48, 68, 65, 86, 106,
              125, 160, 179.5, 163, 155.5, 168, 170, 160.5, 115.5, 119.5, 85,
              58, 58, 53, 52, 36, 32, 24, 27, 19, 15, 12, 14, 10, 8, 5, 5, 8,
              4, 10, 6, 8, 5, 4, 6, 0, 0, 1.5, 1, 4, 3, 2, 0, 2, 1, 1.5, 2, 3,
              2, 2, 1, 1, 1, 1, 3, 2, 2, 2, 2, 0, 2, 5, 3, 1, 1, 3, 1, 2, 2,
              1, 4, 1, 0, 2, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0,
              2, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1.5, 0, 0, 0, 0, 0, 1, 0, 0,
              1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0,
              1, 0, 0, 2, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0
            ],
            "spamo_html": "spamo_out_1/spamo.html",
            "fimo_gff": "fimo_out_1/fimo.gff"
          }, {
            "prog": "centrimo",
            "db": -2,
            "id": "GGGHCCM",
            "alt": "DREME-1",
            "consensus": "GGGHCCM",
            "len": 7,
            "evalue": "2.7e-1053",
            "sites": 2945,
            "sig": "1.1e-1871",
            "pwm": [
              [0.000000, 0.000000, 1.000000, 0.000000], 
              [0.000000, 0.000000, 1.000000, 0.000000], 
              [0.000000, 0.000000, 1.000000, 0.000000], 
              [0.378268, 0.365705, 0.000000, 0.256027], 
              [0.000000, 1.000000, 0.000000, 0.000000], 
              [0.000000, 1.000000, 0.000000, 0.000000], 
              [0.555178, 0.444822, 0.000000, 0.000000]
            ],
            "tomtom_matches": [],
            "centrimo_total_sites": 2915,
            "centrimo_sites": [
              2, 0, 0, 0.25, 0.25, 0, 1.25, 0.25, 0, 1.5, 0.833333, 0.333333,
              0.5, 0.75, 1.25, 0, 0.25, 0.75, 0, 0.5, 0.5, 0.5, 1.25, 0.5,
              0.333333, 0, 0.5, 0.333333, 0.5, 0.5, 1, 0.5, 2, 1.75, 0.25,
              0.333333, 0, 0, 0.75, 1.75, 0.5, 0, 0, 0, 0, 0, 0, 1, 1.5,
              0.333333, 0.333333, 0, 0.25, 2.41667, 0.25, 0.333333, 0.5, 0.5,
              2, 1.33333, 1.33333, 0.5, 0.5, 0.25, 0.25, 0, 0, 0.5, 0.5, 0.5,
              0.5, 0.5, 0, 0.5, 0.366667, 1.5, 0.5, 1, 0, 0, 2.5, 1.75, 1.5,
              2, 2.75, 1.25, 2, 0, 1.5, 3, 2, 2.83333, 3, 2, 4.58333, 2.25,
              1.5, 2.5, 1.75, 0.25, 3.5, 0, 2.33333, 1.83333, 1.5, 0.5, 3.5,
              2.75, 2.25, 2, 2, 2, 1.5, 4.5, 1, 1, 1.25, 1.33333, 8.58333,
              2.75, 2.91667, 5.16667, 3, 4.83333, 4.83333, 5.5, 11.25, 10.25,
              9.25, 8, 12, 3.83333, 15.0333, 12.75, 14.0833, 22.5, 40.1667,
              27.4167, 33.5833, 30.4167, 63.0833, 72.0833, 95.75, 117.167,
              125, 136.867, 177.417, 196.5, 237.583, 175.417, 160.333,
              138.083, 111.417, 90.5, 67.8333, 62.8333, 45.5833, 41.8333,
              30.1667, 28.8333, 30.25, 24.25, 15.5833, 14, 16.8333, 17.2, 8.5,
              11.0833, 7.83333, 8.91667, 2, 3.75, 7.25, 5.75, 10, 6.78333,
              7.2, 4, 2.25, 2.25, 1.75, 2.5, 3.25, 2.83333, 2.5, 2.41667, 2,
              3.25, 0.25, 1.2, 0.783333, 3.58333, 1.5, 0.75, 1, 4.25, 2.75,
              0.5, 1.83333, 2.33333, 1.83333, 0.333333, 1.5, 5.75, 3.75, 0,
              1.91667, 4.08333, 2.5, 3, 1.25, 1.75, 1, 1, 1, 0, 2, 0.25, 2,
              2.91667, 1, 0, 0.5, 1.83333, 0, 0.5, 1, 1.5, 1.5, 1, 0.833333,
              0.2, 1.2, 2, 0, 2.5, 1, 0.25, 1.25, 0, 0, 0, 0, 1, 0.333333,
              0.833333, 0, 0.5, 1.08333, 0.5, 1, 1.5, 0.5, 0.333333, 0.5, 0.5,
              0.5, 1, 0.5, 0, 0.75, 0.333333, 0, 0, 0, 0, 0, 0, 0, 1, 2.25,
              1.5, 0.5, 0.25, 0, 1.16667, 0.666667, 0, 1, 0.833333, 1.16667,
              0.75, 0.5, 1, 0, 0, 0, 1.66667, 2, 0.5, 0, 0.333333, 0, 1
            ]
          }, {
            "prog": "meme",
            "db": -1,
            "id": "CTGAAACCCGRAGTAA",
            "alt": "MEME-4",
            "consensus": "CTGAAACCCGRAGTAA",
            "len": 16,
            "evalue": "2.4e-1350",
            "sites": 919,
            "sig": "2.4e-1350",
            "pwm": [
              [0.019587, 0.763874, 0.007617, 0.208923], 
              [0.008705, 0.000000, 0.003264, 0.988030], 
              [0.087051, 0.005441, 0.907508, 0.000000], 
              [0.996736, 0.000000, 0.003264, 0.000000], 
              [1.000000, 0.000000, 0.000000, 0.000000], 
              [0.994559, 0.001088, 0.001088, 0.003264], 
              [0.001088, 0.837867, 0.000000, 0.161045], 
              [0.005441, 0.939064, 0.000000, 0.055495], 
              [0.016322, 0.902067, 0.003264, 0.078346], 
              [0.236126, 0.003264, 0.760609, 0.000000], 
              [0.455930, 0.000000, 0.544070, 0.000000], 
              [0.826986, 0.001088, 0.171926, 0.000000], 
              [0.143634, 0.000000, 0.856366, 0.000000], 
              [0.000000, 0.005441, 0.000000, 0.994559], 
              [0.992383, 0.000000, 0.007617, 0.000000], 
              [0.994559, 0.000000, 0.002176, 0.003264]
            ],
            "tomtom_matches": [],
            "centrimo_total_sites": 1022,
            "centrimo_sites": [
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 2,
              0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 3, 0, 1, 1, 0, 1, 2, 2, 3, 2,
              2, 5, 2, 6, 6, 7, 2, 9, 4, 9, 5, 9, 11, 12, 16, 20, 23, 27, 28,
              31, 22, 19, 32, 28, 14, 11, 17, 14, 14, 10, 8, 11, 3, 4, 6, 4,
              6, 3, 3, 4, 3, 0, 3, 6, 6, 14, 12, 11, 8, 10, 16, 18, 18, 22,
              26, 34, 26, 25, 27, 24, 28, 28, 16, 14, 9, 10, 4, 11, 9, 7, 6,
              5, 6, 6, 7, 8, 4, 2, 3, 2, 1, 2, 3, 2, 3, 0, 3, 0, 0, 2, 0, 0,
              0, 1, 3, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0,
              0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,
              0, 0, 0, 0
            ],
            "spamo_html": "spamo_out_2/spamo.html",
            "fimo_gff": "fimo_out_2/fimo.gff"
          }, {
            "prog": "meme",
            "db": -1,
            "id": "CCCACCCCGAATTTC",
            "alt": "MEME-2",
            "consensus": "CCCACCCCGAATTTC",
            "len": 15,
            "evalue": "6.7e-1223",
            "sites": 869,
            "sig": "6.7e-1223",
            "pwm": [
              [0.010357, 0.905639, 0.069045, 0.014960], 
              [0.000000, 0.963176, 0.002301, 0.034522], 
              [0.000000, 0.883774, 0.000000, 0.116226], 
              [0.973533, 0.000000, 0.026467, 0.000000], 
              [0.006904, 0.933257, 0.000000, 0.059839], 
              [0.002301, 0.974684, 0.000000, 0.023015], 
              [0.002301, 0.948216, 0.000000, 0.049482], 
              [0.009206, 0.909091, 0.000000, 0.081703], 
              [0.188723, 0.002301, 0.808976, 0.000000], 
              [0.875719, 0.000000, 0.124281, 0.000000], 
              [0.996548, 0.000000, 0.000000, 0.003452], 
              [0.006904, 0.065593, 0.000000, 0.927503], 
              [0.000000, 0.000000, 0.000000, 1.000000], 
              [0.000000, 0.000000, 0.000000, 1.000000], 
              [0.000000, 0.929804, 0.000000, 0.070196]
            ],
            "tomtom_matches": [],
            "centrimo_total_sites": 1112,
            "centrimo_sites": [
              1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1,
              0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0,
              2, 3, 0, 2, 2, 0, 3, 4, 3, 2, 8, 2, 8, 4, 9, 11, 10, 16, 21, 21,
              25, 28, 28, 22, 20, 34, 27, 15, 13, 17, 17, 9, 9, 10, 9, 6, 5,
              4, 3, 5, 4, 7, 4, 11, 9, 7, 4, 6, 7, 2, 3, 1, 2, 2, 0, 1, 1, 3,
              1, 4, 3, 1, 1, 4, 1, 4, 2, 0, 6, 3, 1, 3, 9, 3, 10, 5, 6, 8, 7,
              4, 2, 2, 4, 7, 6, 11, 13, 8, 8, 10, 19, 18, 20, 22, 25, 33, 25,
              26, 26, 27, 29, 26, 15, 12, 10, 10, 3, 10, 10, 5, 7, 5, 7, 6, 3,
              3, 4, 1, 1, 1, 0, 0, 2, 0, 3, 0, 3, 0, 0, 1, 0, 0, 0, 1, 2, 1,
              1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0
            ],
            "spamo_html": "spamo_out_3/spamo.html",
            "fimo_gff": "fimo_out_3/fimo.gff"
          }, {
            "prog": "meme",
            "db": -1,
            "id": "TTTTCGGTAAATTTT",
            "alt": "MEME-3",
            "consensus": "TTTTCGGTAAATTTT",
            "len": 15,
            "evalue": "3.1e-1194",
            "sites": 949,
            "sig": "3.1e-1194",
            "pwm": [
              [0.135933, 0.010537, 0.000000, 0.853530], 
              [0.000000, 0.000000, 0.004215, 0.995785], 
              [0.000000, 0.010537, 0.000000, 0.989463], 
              [0.016860, 0.000000, 0.003161, 0.979979], 
              [0.017914, 0.791359, 0.004215, 0.186512], 
              [0.285564, 0.000000, 0.699684, 0.014752], 
              [0.040042, 0.000000, 0.959958, 0.000000], 
              [0.000000, 0.000000, 0.005269, 0.994731], 
              [0.947313, 0.003161, 0.035827, 0.013699], 
              [0.860906, 0.000000, 0.102213, 0.036881], 
              [0.930453, 0.000000, 0.000000, 0.069547], 
              [0.233930, 0.107482, 0.000000, 0.658588], 
              [0.000000, 0.013699, 0.000000, 0.986301], 
              [0.001054, 0.121180, 0.000000, 0.877766], 
              [0.006322, 0.005269, 0.000000, 0.988409]
            ],
            "tomtom_matches": [],
            "centrimo_total_sites": 1169,
            "centrimo_sites": [
              0, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0,
              1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0.5, 0, 1, 1, 0, 0, 0, 0, 0, 0, 2,
              0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0.5, 0, 2, 1, 0, 2, 0, 3, 2,
              0, 2, 2, 2, 4, 3, 2, 2, 2, 1, 2, 1, 1, 2, 0, 2, 1, 0, 0, 1, 2,
              0, 3, 2, 1, 1, 2, 1, 0, 1, 0.5, 4, 2, 0, 1, 2, 2, 2, 2, 4, 6, 0,
              3, 1, 1, 4, 6.5, 6, 11.5, 8, 11, 16, 10, 20, 20, 19, 26, 22,
              40.5, 19, 28.5, 26, 27, 30, 25, 16, 13, 8, 11, 5, 10.5, 8, 7, 4,
              5, 6, 5, 4, 3, 2, 4, 2, 2, 3.5, 0, 5, 3, 7, 3, 10, 2, 8, 5, 8,
              9, 12, 19, 24, 23, 26.5, 29.5, 28, 20, 18, 31.5, 32, 13, 14, 16,
              14.5, 15, 13.5, 12, 13, 6, 4, 5, 2, 6, 1, 2, 1, 2, 0, 1, 3, 2,
              4, 2, 2, 1, 0, 0, 0, 1, 1, 2, 1, 2, 1, 1, 0, 1, 2, 2, 0, 1, 0,
              2, 0, 0, 3, 1, 1, 0, 1, 3, 3, 0, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1,
              0, 1, 1, 0, 0, 0, 1, 0, 2, 2, 0, 2, 0, 0, 1, 0, 1, 1, 3, 0, 1,
              1, 1, 0, 0, 2, 0, 0, 0, 0, 2, 0, 1, 1, 1, 2, 0, 0, 1, 2, 4, 3,
              2, 0, 0, 3, 0, 0, 1, 1, 2, 1, 1, 2
            ],
            "spamo_html": "spamo_out_4/spamo.html",
            "fimo_gff": "fimo_out_4/fimo.gff"
          }, {
            "prog": "meme",
            "db": -1,
            "id": "TYGGCATAACCTCCCT",
            "alt": "MEME-5",
            "consensus": "TYGGCATAACCTCCCT",
            "len": 16,
            "evalue": "2.0e-818",
            "sites": 678,
            "sig": "2.0e-818",
            "pwm": [
              [0.001475, 0.000000, 0.000000, 0.998525], 
              [0.001475, 0.570796, 0.004425, 0.423304], 
              [0.179941, 0.001475, 0.809735, 0.008850], 
              [0.277286, 0.000000, 0.719764, 0.002950], 
              [0.008850, 0.706490, 0.160767, 0.123894], 
              [0.980826, 0.008850, 0.007375, 0.002950], 
              [0.255162, 0.000000, 0.007375, 0.737463], 
              [0.991150, 0.000000, 0.008850, 0.000000], 
              [0.994100, 0.000000, 0.002950, 0.002950], 
              [0.004425, 0.696165, 0.000000, 0.299410], 
              [0.005900, 0.945428, 0.000000, 0.048673], 
              [0.004425, 0.004425, 0.001475, 0.989676], 
              [0.078171, 0.784661, 0.000000, 0.137168], 
              [0.005900, 0.907080, 0.000000, 0.087021], 
              [0.019174, 0.884956, 0.004425, 0.091445], 
              [0.010324, 0.035398, 0.000000, 0.954277]
            ],
            "tomtom_matches": [],
            "centrimo_total_sites": 1079,
            "centrimo_sites": [
              0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 0, 0, 1,
              0, 1, 2, 0, 0, 2, 0, 3, 3, 1, 2, 3, 0, 2, 1, 0, 2, 0, 1, 2, 0,
              0, 1, 1, 1, 1, 4, 1, 1, 2, 0, 1, 1, 1, 3, 1, 1, 1, 0, 1, 3, 1,
              3, 3, 3, 3, 1, 2, 0, 4, 4, 7, 15, 5, 12, 12, 10, 20, 16, 19, 20,
              28, 33, 23, 34, 22, 26, 25, 23, 21, 13, 8, 7, 8, 10, 6, 7, 7, 8,
              4, 8, 3, 2, 1, 2, 5, 0, 0, 1, 1, 1, 1, 3, 2, 0, 1, 0, 0, 1, 0,
              0, 2, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 3, 3, 1, 4,
              4, 4, 1, 4, 5, 4, 4, 7, 6, 3, 10, 14, 14, 20, 19, 26, 27, 27,
              25, 20, 31, 29, 16, 12, 17, 9, 16, 13, 13, 9, 8, 4, 3, 2, 4, 2,
              1, 1, 1, 1, 0, 2, 3, 3, 4, 3, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1,
              1, 0, 1, 0, 2, 0, 0, 1, 1, 0, 1, 2, 1, 1, 0, 1, 4, 2, 0, 1, 3,
              1, 2, 1, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
              1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
              1, 0
            ],
            "spamo_html": "spamo_out_5/spamo.html",
            "fimo_gff": "fimo_out_5/fimo.gff"
          }, {
            "prog": "centrimo",
            "db": -2,
            "id": "GAYTTACY",
            "alt": "DREME-4",
            "consensus": "GAYTTACY",
            "len": 8,
            "evalue": "1.5e-208",
            "sites": 743,
            "sig": "2.1e-353",
            "pwm": [
              [0.000000, 0.000000, 1.000000, 0.000000], 
              [1.000000, 0.000000, 0.000000, 0.000000], 
              [0.000000, 0.546433, 0.000000, 0.453567], 
              [0.000000, 0.000000, 0.000000, 1.000000], 
              [0.000000, 0.000000, 0.000000, 1.000000], 
              [1.000000, 0.000000, 0.000000, 0.000000], 
              [0.000000, 1.000000, 0.000000, 0.000000], 
              [0.000000, 0.176312, 0.000000, 0.823688]
            ],
            "tomtom_matches": [],
            "centrimo_total_sites": 782,
            "centrimo_sites": [
              0, 0, 0, 0, 0, 0, 0, 0.5, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              1, 0, 0, 1, 0, 1, 0.5, 0, 2, 0, 0.5, 1, 0, 1, 2, 0, 1, 2, 0, 2,
              2, 1, 3, 2, 1, 2, 1, 0, 2, 1, 2, 1, 2, 3, 1, 2, 1, 6, 3, 7, 3,
              8, 4, 7, 9, 7, 15, 11.5, 14, 17, 20, 23, 17, 13, 24, 20, 13, 12,
              11, 11, 8, 12, 10, 15, 12, 6, 9, 10, 16, 15, 16, 13, 19, 22, 17,
              13.5, 25, 21, 22, 26, 15, 11, 9, 8, 3, 10, 9, 5, 6, 3, 6, 1, 3,
              2, 5, 1, 1, 1, 1, 0, 2, 2, 3, 1, 3, 1, 3, 4, 0, 2, 2, 2, 2, 1,
              2, 1, 1, 0, 0, 0.5, 1, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
              0, 0, 0, 1, 0, 0, 0, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
            ],
            "spamo_html": "spamo_out_6/spamo.html",
            "fimo_gff": "fimo_out_6/fimo.gff"
          }, {
            "prog": "centrimo",
            "db": -2,
            "id": "AAATYCGG",
            "alt": "DREME-2",
            "consensus": "AAATYCGG",
            "len": 8,
            "evalue": "4.1e-248",
            "sites": 1129,
            "sig": "6.5e-331",
            "pwm": [
              [1.000000, 0.000000, 0.000000, 0.000000], 
              [1.000000, 0.000000, 0.000000, 0.000000], 
              [1.000000, 0.000000, 0.000000, 0.000000], 
              [0.000000, 0.000000, 0.000000, 1.000000], 
              [0.000000, 0.169176, 0.000000, 0.830824], 
              [0.000000, 1.000000, 0.000000, 0.000000], 
              [0.000000, 0.000000, 1.000000, 0.000000], 
              [0.000000, 0.000000, 1.000000, 0.000000]
            ],
            "tomtom_matches": [],
            "centrimo_total_sites": 953,
            "centrimo_sites": [
              1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1, 0, 0,
              0, 0, 0, 0, 0, 1.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0.333333, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0.333333,
              0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
              0, 0, 0.5, 0, 0, 0.5, 1, 0, 1, 0, 0, 0, 1.5, 2, 0, 1, 1, 0, 2,
              2.5, 2, 1, 4.5, 1.5, 6.5, 2.83333, 5.5, 8, 8, 13.5, 15, 11,
              17.5, 17.5, 20.5, 15, 10, 22.5, 20.5, 12.5, 13.5, 18, 18.5, 17,
              20, 17.5, 20, 9, 5.5, 9.5, 5.5, 6, 7.5, 4, 5, 3.5, 1.5, 2.33333,
              1, 1.5, 4.5, 2, 2, 1, 2.5, 1, 0.5, 3, 0.5, 4, 2.5, 2.5, 1, 2, 0,
              5, 0, 4.5, 0, 3, 1, 3, 1, 3, 6, 6.5, 10, 6, 4, 8.33333, 9, 9.5,
              13, 11.5, 15.5, 14, 16, 18, 18.5, 20, 18.5, 27.5, 29.5, 21, 18,
              25.5, 19.5, 16.5, 15.5, 10, 9, 8, 8.5, 3, 7, 8, 3, 4, 1, 4, 3,
              2.5, 2.5, 2.5, 2.5, 1, 1, 0, 0, 1, 0, 1, 0, 2, 0, 0.5, 1, 0.5,
              0, 0, 1, 0.5, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 1, 0.5, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0.333333, 0, 1, 1, 1, 0, 1.5,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0, 0
            ]
          }, {
            "prog": "centrimo",
            "db": -2,
            "id": "CACCYTGA",
            "alt": "DREME-5",
            "consensus": "CACCYTGA",
            "len": 8,
            "evalue": "2.7e-174",
            "sites": 689,
            "sig": "1.1e-257",
            "pwm": [
              [0.000000, 1.000000, 0.000000, 0.000000], 
              [1.000000, 0.000000, 0.000000, 0.000000], 
              [0.000000, 1.000000, 0.000000, 0.000000], 
              [0.000000, 1.000000, 0.000000, 0.000000], 
              [0.000000, 0.876633, 0.000000, 0.123367], 
              [0.000000, 0.000000, 0.000000, 1.000000], 
              [0.000000, 0.000000, 1.000000, 0.000000], 
              [1.000000, 0.000000, 0.000000, 0.000000]
            ],
            "tomtom_matches": [],
            "centrimo_total_sites": 717,
            "centrimo_sites": [
              0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0,
              1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
              0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0.5, 0, 0, 0, 1, 0, 0,
              0, 0, 0, 0, 0, 0, 0.5, 1, 0, 0, 1, 0, 1, 0, 3.5, 2, 0.5, 1, 3,
              1, 4, 3, 1, 4, 6, 3, 8.5, 3.5, 7.5, 7, 6, 13, 15, 12, 21.5, 18,
              19, 13, 15, 13.5, 18.5, 8, 7, 13, 11, 7, 7, 8, 8, 4.5, 2, 1,
              1.5, 4, 0, 2, 2, 2, 0, 3, 2, 4.5, 5, 1, 3, 0, 0, 2.5, 1, 2, 3,
              2, 2, 3, 2, 2, 0, 5, 4, 10, 5, 6.5, 6, 13, 14, 13.5, 15, 16, 22,
              14, 9.5, 27, 16, 17, 17, 13, 9, 6.5, 9, 5, 10, 11, 5.5, 5, 2,
              3.5, 4, 2, 4, 2, 2, 2, 0, 0, 0, 2, 1, 2, 1, 2.5, 0, 1, 0, 0, 0,
              0, 2, 2, 0, 0, 1, 0.5, 1, 0, 0.5, 1, 0, 0, 0.5, 0, 0, 0, 0, 0,
              0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1,
              1, 0
            ]
          }, {
            "prog": "centrimo",
            "db": -2,
            "id": "AARTTTAC",
            "alt": "DREME-3",
            "consensus": "AARTTTAC",
            "len": 8,
            "evalue": "4.1e-188",
            "sites": 668,
            "sig": "8.1e-232",
            "pwm": [
              [1.000000, 0.000000, 0.000000, 0.000000], 
              [1.000000, 0.000000, 0.000000, 0.000000], 
              [0.848802, 0.000000, 0.151198, 0.000000], 
              [0.000000, 0.000000, 0.000000, 1.000000], 
              [0.000000, 0.000000, 0.000000, 1.000000], 
              [0.000000, 0.000000, 0.000000, 1.000000], 
              [1.000000, 0.000000, 0.000000, 0.000000], 
              [0.000000, 1.000000, 0.000000, 0.000000]
            ],
            "tomtom_matches": [],
            "centrimo_total_sites": 778,
            "centrimo_sites": [
              0, 0, 0, 1.16667, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0, 1, 0, 0.5, 0,
              0, 0, 0, 0, 1, 0, 0.5, 0, 0.333333, 1, 0.333333, 1, 0, 0, 0, 2,
              0, 0, 1, 0, 1.5, 0.5, 1.5, 3.5, 0, 3.5, 3, 0, 1.5, 2.5, 2, 2, 5,
              0, 2, 2, 1, 2.5, 3, 0, 2, 1, 1, 1, 0, 2, 1, 0.5, 0, 1, 1, 0, 1,
              1, 0, 1, 2, 1, 0, 1, 1, 3.5, 0, 1, 1, 0, 2, 2, 2, 1.5, 3, 0,
              3.16667, 0, 1, 2, 2.5, 3, 5, 7, 4, 7.5, 6.5, 13, 11, 13.5, 13.5,
              16.5, 25.5, 14.5, 11.5, 23, 18.5, 18.1667, 21, 11, 8, 8, 7, 3,
              7, 7, 4, 3, 2, 7, 2, 3, 5.5, 1, 4.5, 2, 3, 1, 5.5, 4, 4, 5, 8.5,
              10, 10, 10, 13, 15.5, 19, 21.5, 16.5, 13, 12, 17.5, 19, 8, 7, 8,
              9.5, 10, 8.5, 7.5, 9, 3, 2, 5, 2, 3, 0, 2, 1, 2, 0, 1, 3, 2, 4,
              1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0.5, 1, 0, 2, 0, 0, 0, 1,
              1, 0, 2, 1, 2, 0, 3, 2.5, 2, 0, 2, 2, 2.5, 1.5, 1, 0.5, 1, 1,
              0.5, 1, 0, 1, 1, 0.5, 0, 0, 1, 0.5, 0, 0, 0, 0.5, 0, 2,
              0.166667, 0, 1, 0, 1, 0.5, 0, 0, 1, 0, 0.5, 0, 0.5, 0, 0, 0, 1,
              0, 1.33333, 0, 0.5, 0.166667, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1,
              0, 0, 0, 0, 0, 1.16667, 1, 0.5, 0, 0, 1, 0, 1
            ]
          }
        ],
        "groups": [
          [
            {
              "motif": 0,
              "rc": false,
              "offset": 0
            }, {
              "motif": 1,
              "rc": true,
              "offset": 6
            }
          ], [
            {
              "motif": 2,
              "rc": false,
              "offset": 0
            }
          ], [
            {
              "motif": 3,
              "rc": false,
              "offset": 0
            }, {
              "motif": 7,
              "rc": true,
              "offset": 6
            }, {
              "motif": 8,
              "rc": false,
              "offset": 2
            }
          ], [
            {
              "motif": 4,
              "rc": false,
              "offset": 0
            }, {
              "motif": 9,
              "rc": true,
              "offset": 6
            }
          ], [
            {
              "motif": 5,
              "rc": false,
              "offset": 0
            }
          ], [
            {
              "motif": 6,
              "rc": false,
              "offset": 0
            }
          ]
        ]
      };
    </script>
    <script>
var site_url = "http://meme-suite.org";
</script>
    <script>
/*
 * $
 *
 * Shorthand function for getElementById
 */
function $(el) {
  return document.getElementById(el);
}


/*
 * See http://stackoverflow.com/a/5450113/66387
 * Does string multiplication like the perl x operator.
 */
function string_mult(pattern, count) {
    if (count < 1) return '';
    var result = '';
    while (count > 1) {
        if (count & 1) result += pattern;
        count >>= 1, pattern += pattern;
    }
    return result + pattern;
}

/*
 * See http://stackoverflow.com/questions/814613/how-to-read-get-data-from-a-url-using-javascript
 * Slightly modified with information from
 * https://developer.mozilla.org/en/DOM/window.location
 */
function parse_params() {
  "use strict";
  var search, queryStart, queryEnd, query, params, nvPairs, i, nv, n, v;
  search = window.location.search;
  queryStart = search.indexOf("?") + 1;
  queryEnd   = search.indexOf("#") + 1 || search.length + 1;
  query      = search.slice(queryStart, queryEnd - 1);

  if (query === search || query === "") return {};

  params  = {};
  nvPairs = query.replace(/\+/g, " ").split("&");

  for (i = 0; i < nvPairs.length; i++) {
    nv = nvPairs[i].split("=");
    n  = decodeURIComponent(nv[0]);
    v  = decodeURIComponent(nv[1]);
    // allow a name to be used multiple times
    // storing each value in the array
    if (!(n in params)) {
      params[n] = [];
    }
    params[n].push(nv.length === 2 ? v : null);
  }
  return params;
}

/*
 * coords
 *
 * Calculates the x and y offset of an element.
 * From http://www.quirksmode.org/js/findpos.html
 * with alterations to take into account scrolling regions
 */
function coords(elem) {
  var myX = myY = 0;
  if (elem.getBoundingClientRect) {
    var rect;
    rect = elem.getBoundingClientRect();
    myX = rect.left + ((typeof window.pageXOffset !== "undefined") ?
        window.pageXOffset : document.body.scrollLeft);
    myY = rect.top + ((typeof window.pageYOffset !== "undefined") ?
        window.pageYOffset : document.body.scrollTop);
  } else {
    // this fall back doesn't properly handle absolutely positioned elements
    // inside a scrollable box
    var node;
    if (elem.offsetParent) {
      // subtract all scrolling
      node = elem;
      do {
        myX -= node.scrollLeft ? node.scrollLeft : 0;
        myY -= node.scrollTop ? node.scrollTop : 0;
      } while (node = node.parentNode);
      // this will include the page scrolling (which is unwanted) so add it back on
      myX += (typeof window.pageXOffset !== "undefined") ? window.pageXOffset : document.body.scrollLeft;
      myY += (typeof window.pageYOffset !== "undefined") ? window.pageYOffset : document.body.scrollTop;
      // sum up offsets
      node = elem;
      do {
        myX += node.offsetLeft;
        myY += node.offsetTop;
      } while (node = node.offsetParent);
    }
  }
  return [myX, myY];
}

/*
 * position_popup
 *
 * Positions a popup relative to an anchor element.
 *
 * The available positions are:
 * 0 - Centered below the anchor.
 */
function position_popup(anchor, popup, position) {
  "use strict";
  var a_x, a_y, a_w, a_h, p_x, p_y, p_w, p_h;
  var a_xy, spacer, margin, scrollbar, page_w;
  // define constants
  spacer = 5;
  margin = 15;
  scrollbar = 15;
  // define the positions and widths
  a_xy = coords(anchor);
  a_x = a_xy[0];
  a_y = a_xy[1];
  a_w = anchor.offsetWidth;
  a_h = anchor.offsetHeight;
  p_w = popup.offsetWidth;
  p_h = popup.offsetHeight;
  page_w = null;
  if (window.innerWidth) {
    page_w = window.innerWidth;
  } else if (document.body) {
    page_w = document.body.clientWidth;
  }
  // check the position type is defined
  if (typeof position !== "number") {
    position = 0;
  }
  // calculate the popup position
  switch (position) {
    case 1:
      p_x = a_x + a_w + spacer;
      p_y = a_y + (a_h / 2) - (p_h / 2);
      break;
    case 0:
    default:
      p_x = a_x + (a_w / 2) - (p_w / 2);
      p_y = a_y + a_h + spacer;
      break;
  }
  // constrain the popup position
  if (p_x < margin) {
    p_x = margin;
  } else if (page_w != null && (p_x + p_w) > (page_w - margin - scrollbar)) {
    p_x = page_w - margin - scrollbar - p_w;
  }
  if (p_y < margin) {
    p_y = margin;
  }
  // position the popup
  popup.style.left = p_x + "px";
  popup.style.top = p_y + "px";
}

function lookup_help_popup(popup_id) {
  var _body, pop, info;
  pop = document.getElementById(popup_id);
  if (pop == null) {
    _body = document.getElementsByTagName("body")[0];
    pop = document.createElement("div");
    pop.className = "pop_content";
    pop.id = popup_id;
    pop.style.backgroundColor = "#FFC";
    pop.style.borderColor = "black";
    info = document.createElement("p");
    info.style.fontWeight = "bold";
    info.appendChild(document.createTextNode("Error: No popup for topic \"" + popup_id + "\"."));
    pop.appendChild(info);
    // this might cause problems with the menu, but as this only happens
    // when something is already wrong I don't think that's too much of a problem
    _body.insertBefore(pop, _body.firstChild);
  }
  if (document.getElementsByTagName('body')[0].hasAttribute("data-autobtns")) {
    if (!/\bauto_buttons\b/.test(pop.className)) {
      pop.className += " auto_buttons";
      var back_btn_sec = document.createElement("div");
      back_btn_sec.className = "nested_only pop_back_sec";
      var back_btn = document.createElement("span");
      back_btn.className = "pop_back";
      back_btn.appendChild(document.createTextNode("<< back"));
      back_btn.addEventListener("click", function(e) {
        help_return();
      }, false);
      back_btn_sec.appendChild(back_btn);
      pop.insertBefore(back_btn_sec, pop.firstChild);
      var close_btn_sec = document.createElement("div");
      close_btn_sec.className = "pop_close_sec";
      var close_btn = document.createElement("span");
      close_btn.className = "pop_close";
      close_btn.appendChild(document.createTextNode("close"));
      close_btn.addEventListener("click", function(e) {
        help_popup();
      }, false);
      close_btn_sec.appendChild(close_btn);
      pop.appendChild(close_btn_sec);
    }
  }
  return pop;
}

/*
 * help_popup
 *
 * Moves around help pop-ups so they appear
 * below an activator.
 */
function help_popup(activator, popup_id) {
  "use strict";
  var pop;
  // set default values
  if (typeof help_popup.popup === "undefined") {
    help_popup.popup = [];
  }
  if (typeof help_popup.activator === "undefined") {
    help_popup.activator = null;
  }
  var last_pop = (help_popup.popup.length > 0 ? help_popup.popup[help_popup.popup.length - 1] : null);
  if (typeof(activator) == "undefined") { // no activator so hide
    if (last_pop != null) {
      last_pop.style.display = 'none';
      help_popup.popup = [];
    }
    return;
  }
  pop = lookup_help_popup(popup_id);
  if (pop == last_pop) {
    if (activator == help_popup.activator) {
      //hide popup (as we've already shown it for the current help button)
      last_pop.style.display = 'none';
      help_popup.popup = [];
      return; // toggling complete!
    }
  } else if (last_pop != null) {
    //activating different popup so hide current one
    last_pop.style.display = 'none';
  }
  help_popup.popup = [pop];
  help_popup.activator = activator;
  toggle_class(pop, "nested", false);
  //must make the popup visible to measure it or it has zero width
  pop.style.display = 'block';
  position_popup(activator, pop);
}

/*
 * help_refine
 * 
 * Intended for links within a help popup. Stores a stack of state so
 * you can go back.
 */
function help_refine(popup_id) {
  if (help_popup.popup == null || help_popup.popup.length == 0 || help_popup.activator == null) {
    //throw new Error("Cannot refine a help popup when one is not shown!");
    var pop = lookup_help_popup(popup_id);
    var act_id = popup_id + '_act';
    var activator = document.getElementById(act_id);
    help_popup(activator, popup_id);
  }
  var pop = lookup_help_popup(popup_id);
  var last_pop = help_popup.popup[help_popup.popup.length - 1];
  if (pop == last_pop) return; // slightly odd, but no real cause for alarm
  help_popup.popup.push(pop);
  toggle_class(pop, "nested", true);
  last_pop.style.display = "none";
  //must make the popup visible to measure it or it has zero width
  pop.style.display = "block";
  position_popup(help_popup.activator, pop);
}

/*
 * help_return
 * 
 * Intended for links within a help popup. Stores a stack of state so
 * you can go back.
 */
function help_return() {
  if (help_popup.popup == null || help_popup.popup.length == 0 || help_popup.activator == null) {
    throw new Error("Can not return to a earlier help popup when one is not shown!");
  }
  var last_pop = help_popup.popup.pop();
  last_pop.style.display = "none";
  var pop = (help_popup.popup.length > 0 ? help_popup.popup[help_popup.popup.length - 1] : null);
  if (pop != null) {
    toggle_class(pop, "nested", help_popup.popup.length > 1);
    pop.style.display = "block";
    position_popup(help_popup.activator, pop);
  } else {
    help_popup.activator = null;
  }
}

/*
 * update_scroll_pad
 *
 * Creates padding at the bottom of the page to allow
 * scrolling of anything into view.
 */
function update_scroll_pad() {
  var page, pad;
  page = (document.compatMode === "CSS1Compat") ? document.documentElement : document.body;
  pad = $("scrollpad");
  if (pad === null) {
    pad = document.createElement("div");
    pad.id = 'scrollpad';
    document.getElementsByTagName('body')[0].appendChild(pad);
  }
  pad.style.height = Math.abs(page.clientHeight - 100) + "px";
}

function substitute_classes(node, remove, add) {
  "use strict";
  var list, all, i, cls, classes;
  list = node.className.split(/\s+/);
  all = {};
  for (i = 0; i < list.length; i++) {
    if (list[i].length > 0) all[list[i]] = true;
  }
  for (i = 0; i < remove.length; i++) {
    if (all.hasOwnProperty(remove[i])) {
      delete all[remove[i]];
    }
  }
  for (i = 0; i < add.length; i++) {
    all[add[i]] = true;
  }
  classes = "";
  for (cls in all) {
    classes += cls + " ";
  }
  node.className = classes;
}

/*
 * toggle_class
 *
 * Adds or removes a class from the node. If the parameter 'enabled' is not 
 * passed then the existence of the class will be toggled, otherwise it will be
 * included if enabled is true.
 */
function toggle_class(node, cls, enabled) {
  var classes = node.className;
  var list = classes.replace(/^\s+/, '').replace(/\s+$/, '').split(/\s+/);
  var found = false;
  for (var i = 0; i < list.length; i++) {
    if (list[i] == cls) {
      list.splice(i, 1);
      i--;
      found = true;
    }
  }
  if (typeof enabled == "undefined") {
    if (!found) list.push(cls);
  } else {
    if (enabled) list.push(cls);
  }
  node.className = list.join(" ");
}

/*
 * find_child
 *
 * Searches child nodes in depth first order and returns the first it finds
 * with the className specified.
 * TODO replace with querySelector
 */
function find_child(node, className) {
  var pattern;
  if (node == null || typeof node !== "object") {
    return null;
  }
  if (typeof className === "string") {
    pattern = new RegExp("\\b" + className + "\\b");
  } else {
    pattern = className;
  }
  if (node.nodeType == Node.ELEMENT_NODE && 
      pattern.test(node.className)) {
    return node;
  } else {
    var result = null;
    for (var i = 0; i < node.childNodes.length; i++) {
      result = find_child(node.childNodes[i], pattern);
      if (result != null) break;
    }
    return result;
  }
}

/*
 * find_parent
 *
 * Searches parent nodes outwards from the node and returns the first it finds
 * with the className specified.
 */
function find_parent(node, className) {
  var pattern;
  pattern = new RegExp("\\b" + className + "\\b");
  do {
    if (node.nodeType == Node.ELEMENT_NODE && 
        pattern.test(node.className)) {
      return node;
    }
  } while (node = node.parentNode);
  return null;
}

/*
 * find_parent_tag
 *
 * Searches parent nodes outwards from the node and returns the first it finds
 * with the tag name specified. HTML tags should be specified in upper case.
 */
function find_parent_tag(node, tag_name) {
  do {
    if (node.nodeType == Node.ELEMENT_NODE && node.tagName == tag_name) {
      return node;
    }
  } while (node = node.parentNode);
  return null;
}

/*
 * __toggle_help
 *
 * Uses the 'topic' property of the this object to
 * toggle display of a help topic.
 *
 * This function is not intended to be called directly.
 */
function __toggle_help(e) {
  if (!e) e = window.event;
  if (e.type === "keydown") {
    if (e.keyCode !== 13 && e.keyCode !== 32) {
      return;
    }
    // stop a submit or something like that
    e.preventDefault();
  }

  help_popup(this, this.getAttribute("data-topic"));
}

function setup_help_button(button) {
  "use strict";
  var topic;
  if (button.hasAttribute("data-topic")) {
    topic = button.getAttribute("data-topic");
    if (document.getElementById(topic) != null) {
      button.tabIndex = "0"; // make keyboard selectable
      button.addEventListener("click", function() {
        help_popup(button, topic);
      }, false);
      button.addEventListener("keydown", function(e) {
        // toggle only on Enter or Spacebar, let other keys do their thing
        if (e.keyCode !== 13 && e.keyCode !== 32) return;
        // stop a submit or something like that
        e.preventDefault();
        help_popup(button, topic);
      }, false);
    } else {
      button.style.visibility = "hidden";
    }
  }
  button.className += " active";
}

/*
 * help_button
 *
 * Makes a help button for the passed topic.
 */
function help_button(topic) {
  var btn = document.createElement("div");
  btn.className = "help";
  btn.setAttribute("data-topic", topic);
  setup_help_button(btn);
  return btn;
}

/*
 * prepare_download
 *
 * Sets the attributes of a link to setup a file download using the given content.
 * If no link is provided then create one and click it.
 */
function prepare_download(content, mimetype, filename, link) {
  "use strict";
  // if no link is provided then create one and click it
  var click_link = false;
  if (!link) {
    link = document.createElement("a");
    click_link = true;
  }
  try {
    // Use a BLOB to convert the text into a data URL.
    // We could do this manually with a base 64 conversion.
    // This will only be supported on modern browsers,
    // hence the try block.
    var blob = new Blob([content], {type: mimetype});
    var reader = new FileReader();
    reader.onloadend = function() {
      // If we're lucky the browser will also support the download
      // attribute which will let us suggest a file name to save the link.
      // Otherwise it is likely that the filename will be unintelligible. 
      link.setAttribute("download", filename);
      link.href = reader.result;
      if (click_link) {
        // must add the link to click it
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
      }
    }
    reader.readAsDataURL(blob);
  } catch (error) {
    if (console && console.log) console.log(error);
    // probably an old browser
    link.href = "";
    link.visible = false;
  }
}

/*
 * add_cell
 *
 * Add a cell to the table row.
 */
function add_cell(row, node, cls, click_action) {
  var cell = row.insertCell(row.cells.length);
  if (node) cell.appendChild(node);
  if (cls && cls !== "") cell.className = cls;
  if (click_action) cell.addEventListener("click", click_action, false);
}

/*
 * add_header_cell
 *
 * Add a header cell to the table row.
 */
function add_header_cell(row, node, help_topic, cls, colspan) {
  var th = document.createElement("th");
  if (node) th.appendChild(node);
  if (help_topic && help_topic !== "") th.appendChild(help_button(help_topic));
  if (cls && cls !== "") th.className = cls;
  if (typeof colspan == "number" && colspan > 1) th.colSpan = colspan;
  row.appendChild(th);
}

/*
 * add_text_cell
 *
 * Add a text cell to the table row.
 */
function add_text_cell(row, text, cls, action) {
  var node = null;
  if (typeof(text) != 'undefined') node = document.createTextNode(text);
  add_cell(row, node, cls, action);
}

/*
 * add_text_header_cell
 *
 * Add a text header cell to the table row.
 */
function add_text_header_cell(row, text, help_topic, cls, action, colspan) {
  var node = null;
  if (typeof(text) != 'undefined') {
    var nbsp = (help_topic ? "\u00A0" : "");
    var str = "" + text;
    var parts = str.split(/\n/);
    if (parts.length === 1) {
      if (action) {
        node = document.createElement("span");
        node.appendChild(document.createTextNode(str + nbsp));
      } else {
        node = document.createTextNode(str + nbsp);
      }
    } else {
      node = document.createElement("span");
      for (var i = 0; i < parts.length; i++) {
        if (i !== 0) {
          node.appendChild(document.createElement("br"));
        }
        node.appendChild(document.createTextNode(parts[i]));
      }
    }
    if (action) {
      node.addEventListener("click", action, false);
      node.style.cursor = "pointer";
    }
  }
  add_header_cell(row, node, help_topic, cls, colspan);
}

function setup_help() {
  "use strict";
  var help_buttons, i;
  help_buttons = document.querySelectorAll(".help:not(.active)");
  for (i = 0; i < help_buttons.length; i++) {
    setup_help_button(help_buttons[i]);
  }
}

function setup_scrollpad() {
  "use strict";
  if (document.getElementsByTagName('body')[0].hasAttribute("data-scrollpad") && document.getElementById("scrollpad") == null) {
    window.addEventListener("resize", update_scroll_pad, false);
    update_scroll_pad();
  }
}

// anon function to avoid polluting global scope
(function() {
  "use strict";
  window.addEventListener("load", function load(evt) {
    window.removeEventListener("load", load, false);
    setup_help();
    setup_scrollpad();
  }, false);
})();

/*
 *  make_link
 *
 *  Creates a text node and if a URL is specified it surrounds it with a link.
 *  If the URL doesn't begin with "http://" it automatically adds it, as
 *  relative links don't make much sense in this context.
 */
function make_link(text, url) {
  var textNode = null;
  var link = null;
  if (typeof text !== "undefined" && text !== null) textNode = document.createTextNode(text);
  if (typeof url === "string") {
    if (url.indexOf("//") == -1) {
      url = "http://" + url;
    }
    link = document.createElement('a');
    link.href = url;
    if (textNode) link.appendChild(textNode);
    return link;
  }
  return textNode;
}

//
// Function to create an HTML paragraph describing the 
// MEME Suite background model source.
//
function make_background_source(title, source, text) {
  var paraNode = document.createElement("P");
  var titleNode = document.createElement("B");
  var textNode1 = document.createTextNode("\u00A0\u00A0\u00A0\u00A0" + title + ": ");
  titleNode.appendChild(textNode1);
  var source_text = ((source == "--motif--") ? "the (first) motif file" : (source == "--nrdb--") ? "an old version of the NCBI non-redundant database" : (source == "--uniform--") ? "the uniform model" : (source == "--query--") ? "the query file" : (source == "--sequences--") ? "built from the (primary) sequences" : ("the file '" + source + "'"));
  if (text) { return source_text; }
  var textNode2 = document.createTextNode(source_text);
  paraNode.appendChild(titleNode);
  paraNode.appendChild(textNode2);
  return paraNode;
}

// Function to create a help button
function make_help_button(container, help_topic) {
  container.appendChild(help_button(help_topic));
}
</script>
    <script>
//======================================================================
// start Alphabet object
//======================================================================
var Alphabet = function(alphabet, background) {
  "use strict";
  var i, j, sym, aliases, complement, comp_e_sym, ambigs, generate_background;
  generate_background = (background == null);
  if (generate_background) {
    background = [];
    for (i = 0; i < alphabet.ncore; i++) background[i] = 1.0 / alphabet.ncore;
  } else if (alphabet.ncore != background.length) {
    throw new Error("The background length does not match the alphabet length.");
  }
  this.name = alphabet.name;
  this.like = (alphabet.like != null ? alphabet.like.toUpperCase() : null);
  this.ncore = alphabet.ncore;
  this.symbols = alphabet.symbols;
  this.background = background;
  this.genbg = generate_background;
  this.encode = {};
  this.encode2core = {};
  this.complement = {};
  // check if all symbols are same case
  var seen_uc = false;
  var seen_lc = false;
  var check_case = function (syms) {
    var s, sym;
    if (typeof syms === "string") {
      for (s = 0; s < syms.length; s++) {
        sym = syms.charAt(s);
        if (sym >= 'a' && sym <= 'z') seen_lc = true;
        else if (sym >= 'A' && sym <= 'Z') seen_uc = true;
      }
    }
  };
  for (i = 0; i < this.symbols.length; i++) {
    check_case(this.symbols[i].symbol);
    check_case(this.symbols[i].aliases);
  }
  // now map symbols to indexes
  var update_array = function(array, syms, index) {
    var s, sym;
    if (typeof syms === "string") {
      for (s = 0; s < syms.length; s++) {
        sym = syms.charAt(s);
        array[sym] = index;
        // when only a single case is used, then encode as case insensitive
        if (seen_uc != seen_lc) {
          if (sym >= 'a' && sym <= 'z') {
            array[sym.toUpperCase()] = index;
          } else if (sym >= 'A' && sym <= 'Z') {
            array[sym.toLowerCase()] = index;
          }
        }
      }
    }
  }
  // map core symbols to index
  for (i = 0; i < this.ncore; i++) {
    update_array(this.encode2core, this.symbols[i].symbol, i);
    update_array(this.encode, this.symbols[i].symbol, i);
    update_array(this.encode2core, this.symbols[i].aliases, i);
    update_array(this.encode, this.symbols[i].aliases, i);
  }
  // map ambiguous symbols to index
  ambigs = {};
  for (i = this.ncore; i < this.symbols.length; i++) {
    update_array(this.encode, this.symbols[i].symbol, i);
    update_array(this.encode, this.symbols[i].aliases, i);
    ambigs[this.symbols[i].equals] = i;
  }
  // determine complements
  for (i = 0; i < this.ncore; i++) {
    complement = this.symbols[i].complement;
    if (typeof complement === "string") {
      this.complement[i] = this.encode2core[complement];
    }
  }
  next_symbol:
  for (i = this.ncore; i < this.symbols.length; i++) {
    complement = "";
    for (j = 0; j < this.symbols[i].equals.length; j++) {
      comp_e_sym = this.complement[this.encode2core[this.symbols[i].equals.charAt(j)]];
      if (typeof comp_e_sym !== "number") continue next_symbol;
      complement += this.symbols[comp_e_sym].symbol;
    }
    complement = complement.split("").sort().join("");
    if (typeof ambigs[complement] === "number") {
      this.complement[i] = ambigs[complement];
    }
  }
  // determine case insensitivity
  this.case_insensitive = true;
  if (seen_uc == seen_lc) {
    // when there is a mixture of cases it probably won't
    // be case insensitive but we still need to check
    loop:
    for (i = 0; i < this.symbols.length; i++) {
      sym = this.symbols[i].symbol;
      if (sym >= 'A' && sym <= 'Z') {
        if (this.encode[sym.toLowerCase()] != i) {
          this.case_insensitive = false;
          break loop;
        }
      } else if (sym >= 'a' && sym <= 'z') {
        if (this.encode[sym.toUpperCase()] != i) {
          this.case_insensitive = false;
          break loop;
        }
      }
      aliases = this.symbols[i].aliases;
      if (aliases != null) {
        for (j = 0; j < aliases.length; j++) {
          sym = aliases.charAt(j);
          if (sym >= 'A' && sym <= 'Z') {
            if (this.encode[sym.toLowerCase()] != i) {
              this.case_insensitive = false;
              break loop;
            }
          } else if (sym >= 'a' && sym <= 'z') {
            if (this.encode[sym.toUpperCase()] != i) {
              this.case_insensitive = false;
              break loop;
            }
          }
        }
      }
    }
  }
  // normalise aliases to remove the prime symbol and eliminate
  // the alternate cases when the alphabet is case insensitive
  var seen, out;
  for (i = 0; i < this.symbols.length; i++) {
    sym = this.symbols[i].symbol;
    aliases = this.symbols[i].aliases;
    if (typeof aliases != "string") aliases = "";
    seen = {};
    out = [];
    if (this.case_insensitive) {
      sym = sym.toUpperCase();
      aliases = aliases.toUpperCase();
    }
    seen[sym] = true;
    for (j = 0; j < aliases.length; j++) {
      if (!seen[aliases.charAt(j)]) {
        seen[aliases.charAt(j)] = true;
        out.push(aliases.charAt(j));
      }
    }
    this.symbols[i].aliases = out.sort().join("");
  }
};
// return the name of the alphabet
Alphabet.prototype.get_alphabet_name = function() {
  return this.name;
};
// return if the alphabet can be complemented
Alphabet.prototype.has_complement = function() {
  return (typeof this.symbols[0].complement === "string");
};
// return true if an uppercase letter has the same meaning as the lowercase form
Alphabet.prototype.is_case_insensitive = function() {
  return this.case_insensitive;
};
// return the information content of an alphabet letter
Alphabet.prototype.get_ic = function() {
  return Math.log(this.ncore) / Math.LN2;
};
// return the count of the core alphabet symbols
Alphabet.prototype.get_size_core = function() {
  return this.ncore;
};
// return the count of all alphabet symbols
Alphabet.prototype.get_size_full = function() {
  return this.symbols.length;
};
// return the symbol for the given alphabet index
Alphabet.prototype.get_symbol = function(alph_index) {
  "use strict";
  if (alph_index < 0 || alph_index >= this.symbols.length) {
    throw new Error("Alphabet index out of bounds");
  }
  return this.symbols[alph_index].symbol;
};
// return the aliases for the given alphabet index
Alphabet.prototype.get_aliases = function(alph_index) {
  "use strict";
  if (alph_index < 0 || alph_index >= this.symbols.length) {
    throw new Error("Alphabet index out of bounds");
  }
  var sym_obj = this.symbols[alph_index];
  return (sym_obj.aliases != null ? sym_obj.aliases : "");
};
// return the name for the given alphabet index
Alphabet.prototype.get_name = function(alph_index) {
  "use strict";
  var sym;
  if (alph_index < 0 || alph_index >= this.symbols.length) {
    throw new Error("Alphabet index out of bounds");
  }
  sym = this.symbols[alph_index];
  return (typeof sym.name === "string" ? sym.name : sym.symbol);
};
// return the alphabet it is like or null
Alphabet.prototype.get_like = function() {
  "use strict";
  return this.like;
};
// return the index of the complement for the given alphabet index
Alphabet.prototype.get_complement = function(alph_index) {
  var comp_e_sym = this.complement[alph_index];
  if (typeof comp_e_sym === "number") {
    return comp_e_sym;
  } else {
    return -1;
  }
};
// return a string containing the core symbols
Alphabet.prototype.get_symbols = function() {
  "use strict";
  var i, core_symbols;
  core_symbols = "";
  for (i = 0; i < this.ncore; i++) {
    core_symbols += this.symbols[i].symbol;
  }
  return core_symbols;
};
// return if the background was not a uniform generated background
Alphabet.prototype.has_bg = function() {
  "use strict";
  return !this.genbg;
};
// get the background frequency for the index
Alphabet.prototype.get_bg_freq = function(alph_index) {
  "use strict";
  var freq, i, symbols;
  if (alph_index >= 0) {
    if (alph_index < this.ncore) {
      return this.background[alph_index];
    } else if (alph_index < this.symbols.length) {
      freq = 0;
      symbols = this.symbols[alph_index].equals;
      for (i = 0; i < symbols.length; i++) {
        freq += this.background[this.encode2core[symbols.charAt(i)]];
      }
      return freq;
    } 
  }
  throw new Error("The alphabet index is out of range.");
};
// get the colour of the index
Alphabet.prototype.get_colour = function(alph_index) {
  "use strict";
  if (alph_index < 0 || alph_index >= this.symbols.length) {
    throw new Error("BAD_ALPHABET_INDEX");
  }
  if (typeof this.symbols[alph_index].colour != "string") {
    return "black";
  }
  return "#" + this.symbols[alph_index].colour;
};
// get the rgb components of the colour at the index
Alphabet.prototype.get_rgb = function(alph_index) {
  "use strict";
  if (alph_index < 0 || alph_index >= this.symbols.length) {
    throw new Error("BAD_ALPHABET_INDEX");
  }
  if (typeof this.symbols[alph_index].colour != "string") {
    return {"red": 0, "green": 0, "blue": 0};
  }
  var colour = this.symbols[alph_index].colour;
  var red = parseInt(colour.substr(0, 2), 16) / 255;
  var green = parseInt(colour.substr(2, 2), 16) / 255;
  var blue = parseInt(colour.substr(4, 2), 16) / 255;
  return {"red": red, "green": green, "blue": blue};
};
// convert a symbol into the index
Alphabet.prototype.get_index = function(letter) {
  "use strict";
  var alph_index;
  alph_index = this.encode[letter];
  if (typeof alph_index === "undefined") {
    return -1;
  }
  return alph_index;
};
// convert a symbol into the list of core indexes that it equals
Alphabet.prototype.get_indexes = function(letter) {
  "use strict";
  var alph_index, comprise_str, i, comprise_list;
  alph_index = this.encode[letter];
  if (typeof alph_index === "undefined") {
    throw new Error("Unknown letter");
  }
  comprise_str = this.symbols[alph_index].equals;
  comprise_list = [];
  if (typeof comprise_str == "string") {
    for (i = 0; i < comprise_str.length; i++) {
      comprise_list.push(this.encode2core[comprise_str.charAt(i)]);
    }
  } else {
    comprise_list.push(alph_index);
  }
  return comprise_list;
};
// check if a symbol is the primary way of representing the symbol in the alphabet
Alphabet.prototype.is_prime_symbol = function(letter) {
  var alph_index;
  alph_index = this.encode[letter];
  if (alph_index == null) return false;
  if (this.is_case_insensitive()) {
    return (this.symbols[alph_index].symbol.toUpperCase() == letter.toUpperCase());
  } else {
    return (this.symbols[alph_index].symbol == letter);
  }
};
// compare 2 alphabets
Alphabet.prototype.equals = function(other) {
  "use strict";
  var i, sym1, sym2;
  // first check that it's actually an alphabet object
  if (!(typeof other === "object" && other != null && other instanceof Alphabet)) {
    return false;
  }
  // second shortcircuit if it's the same object
  if (this === other) return true;
  // compare
  if (this.name !== other.name) return false;
  if (this.ncore !== other.ncore) return false;
  if (this.symbols.length !== other.symbols.length) return false;
  for (i = 0; i < this.symbols.length; i++) {
    sym1 = this.symbols[i];
    sym2 = other.symbols[i];
    if (sym1.symbol !== sym2.symbol) return false;
    if (sym1.aliases !== sym2.aliases) return false;
    if (sym1.name !== sym2.name) return false;
    if (typeof sym1.colour !== typeof sym2.colour || 
        (typeof sym1.colour === "string" && typeof sym2.colour === "string" &&
         parseInt(sym1.colour, 16) != parseInt(sym2.colour, 16))) {
      return false;
    }
    if (sym1.complement !== sym2.complement) return false;
    if (sym1.equals !== sym2.equals) return false;
  }
  return true;
};
Alphabet.prototype.check_core_subset = function(super_alph) {
  var complement_same = true;
  var seen_set = {};
  var sub_i, sub_symbol, super_i, super_symbol;
  for (sub_i = 0; sub_i < this.ncore; sub_i++) {
    sub_symbol = this.symbols[sub_i];
    super_i = super_alph.encode[sub_symbol.symbol]; 
    if (super_i == null) return 0;
    super_symbol = super_alph.symbols[super_i];
    if (seen_set[super_i]) return 0;
    seen_set[super_i] = true;
    // check complement
    if (sub_symbol.complement != null && super_symbol.complement != null) {
      if (super_alph.encode[sub_symbol.complement] != super_alph.encode[super_symbol.complement]) {
        complement_same = false;
      }
    } else if (sub_symbol.complement != null || super_symbol.complement != null) {
      complement_same = false;
    }
  }
  return (complement_same ? 1 : -1);
};
// convert a sequence to its reverse complement
Alphabet.prototype.invcomp_seq = function(seq) {
  "use strict";
  var syms, i, e_sym, comp_e_sym;
  if (!this.has_complement()) throw new Error("Alphabet must be complementable");
  syms = seq.split("");
  for (i = 0; i < syms.length; i++) {
    e_sym = this.encode[syms[i]];
    if (typeof e_sym === "undefined") {
      e_sym = this.ncore; // wildcard
    }
    comp_e_sym = this.complement[e_sym];
    if (typeof comp_e_sym === "undefined") {
      comp_e_sym = e_sym; // not complementable
    }
    syms[i] = this.symbols[comp_e_sym].symbol;
  }
  return syms.reverse().join("");
};
// convert the alphabet to the text version
Alphabet.prototype.as_text = function() {
  "use strict";
  function name_as_text(name) {
    var i, c, out;
    out = "\"";
    for (i = 0; i < name.length; i++) {
      c = name.charAt(i);
      if (c == "\"") {
        out += "\\\"";
      } else if (c == "/") {
        out += "\\/";
      } else if (c == "\\") {
        out += "\\\\";
      } else {
        out += c;
      }
    }
    out += "\"";
    return out;
  }
  function symbol_as_text(sym) {
    var out;
    out = sym.symbol;
    if (typeof sym.name === "string" && sym.name != sym.symbol) {
      out += " " + name_as_text(sym.name);
    }
    if (typeof sym.colour === "string") {
      out += " " + sym.colour;
    }
    return out;
  }
  var out, i, j, c, sym;
  out = "";
  // output core symbols with 2 way complements
  for (i = 0; i < this.ncore; i++) {
    c = this.complement[i];
    if (typeof c === "number" && i < c && this.complement[c] === i) {
      out += symbol_as_text(this.symbols[i]) + " ~ " + symbol_as_text(this.symbols[c]) + "\n";  
    }
  }
  // output core symbols with no complement
  for (i = 0; i < this.ncore; i++) {
    if (typeof this.complement[i] === "undefined") {
      out += symbol_as_text(this.symbols[i]) + "\n";
    }
  }
  // output ambiguous symbols that have comprising characters
  for (i = this.ncore; i < this.symbols.length; i++) {
    if (this.symbols[i].equals.length == 0) break;
    out += symbol_as_text(this.symbols[i]) + " = " + this.symbols[i].equals + "\n";
    if (typeof this.symbols[i].aliases === "string") {
      for (j = 0; j < this.symbols[i].aliases.length; j++) {
        if (this.symbols[i].aliases.charAt(j) == this.symbols[i].symbol) continue;
        out += this.symbols[i].aliases.charAt(j) + " = " + this.symbols[i].equals + "\n";
      }
    }
  }
  // output aliases of core symbols
  for (i = 0; i < this.ncore; i++) {
    if (typeof this.symbols[i].aliases === "string") {
      for (j = 0; j < this.symbols[i].aliases.length; j++) {
        if (this.symbols[i].aliases.charAt(j) == this.symbols[i].symbol) continue;
        out += this.symbols[i].aliases.charAt(j) + " = " + this.symbols[i].symbol + "\n";
      }
    }
  }
  // output gap symbols
  i = this.symbols.length - 1;
  if (this.symbols[i].equals.length == 0) {
    out += symbol_as_text(this.symbols[i]) + " =\n";
    if (typeof this.symbols[i].aliases === "string") {
      for (j = 0; j < this.symbols[i].aliases.length; j++) {
        if (this.symbols[i].aliases.charAt(j) == this.symbols[i].symbol) continue;
        out += this.symbols[i].aliases.charAt(j) + " =\n";
      }
    }
  }
  return out;
};
// output the alphabet as it appears in minimal MEME format
Alphabet.prototype.as_meme = function() {
  "use strict";
  function name_as_text(name) {
    var i, c, out;
    out = "\"";
    for (i = 0; i < name.length; i++) {
      c = name.charAt(i);
      if (c == "\"") {
        out += "\\\"";
      } else if (c == "/") {
        out += "\\/";
      } else if (c == "\\") {
        out += "\\\\";
      } else {
        out += c;
      }
    }
    out += "\"";
    return out;
  }
  if (this.equals(AlphStd.DNA)) {
    return "ALPHABET= ACGT\n";
  } else if (this.equals(AlphStd.PROTEIN)) {
    return "ALPHABET= ACDEFGHIKLMNPQRSTVWY\n";
  } else {
    return "ALPHABET" + 
      (this.name != null ? " " + name_as_text(this.name) : "") + 
      (this.like != null ? " " + this.like + "-LIKE" : "") + "\n" +
      this.as_text() + "END ALPHABET\n";
  }
};

// Returns a table showing all the letters in the alphabet
Alphabet.prototype.as_table = function() {
  "use strict";
  var i, j, row, th, td, aliases, equals, sym;
  var table = document.createElement("table");
  // create the core symbol header
  row = table.insertRow(table.rows.length);
  th = document.createElement("th");
  th.appendChild(document.createTextNode("Symbol(s)"));
  row.appendChild(th);
  th = document.createElement("th");
  th.appendChild(document.createTextNode("Name"));
  row.appendChild(th);
  th = document.createElement("th");
  if (this.has_complement()) {
    th.appendChild(document.createTextNode("Complement"));
  }
  row.appendChild(th);
  // list the core symbols
  for (i = 0; i < this.ncore; i++) {
    row = table.insertRow(table.rows.length);
    td = document.createElement("td");
    if (this.symbols[i].colour != null) {
      td.style.color = '#' + this.symbols[i].colour;
    }
    td.appendChild(document.createTextNode(this.symbols[i].symbol));
    aliases = this.get_aliases(i);
    if (aliases.length > 0) {
      td.appendChild(document.createTextNode(' ' + aliases.split('').join(' ')));
    }
    row.appendChild(td);
    td = document.createElement("td");
    if (this.symbols[i].name != null) {
      td.appendChild(document.createTextNode(this.symbols[i].name));
    }
    row.appendChild(td);
    td = document.createElement("td");
    if (this.symbols[i].complement != null) {
      td.style.color = this.get_colour(this.get_index(this.symbols[i].complement));
      td.appendChild(document.createTextNode(this.symbols[i].complement));
    }
    row.appendChild(td);
  }
  // create the ambiguous symbol header
  row = table.insertRow(table.rows.length);
  th = document.createElement("th");
  th.appendChild(document.createTextNode("Symbol(s)"));
  row.appendChild(th);
  th = document.createElement("th");
  th.appendChild(document.createTextNode("Name"));
  row.appendChild(th);
  th = document.createElement("th");
  th.appendChild(document.createTextNode("Matches"));
  row.appendChild(th);
  // list the ambiguous symbols
  for (i = this.ncore; i < this.symbols.length; i++) {
    row = table.insertRow(table.rows.length);
    td = document.createElement("td");
    if (this.symbols[i].colour != null) {
      td.style.color = '#' + this.symbols[i].colour;
    }
    td.appendChild(document.createTextNode(this.symbols[i].symbol));
    aliases = this.get_aliases(i);
    if (aliases.length > 0) {
      td.appendChild(document.createTextNode(' ' + aliases.split('').join(' ')));
    }
    row.appendChild(td);
    td = document.createElement("td");
    if (this.symbols[i].name != null) {
      td.appendChild(document.createTextNode(this.symbols[i].name));
    }
    row.appendChild(td);
    td = document.createElement("td");
    equals = this.symbols[i].equals.split('');
    for (j = 0; j < equals.length; j++) {
      if (j != 0) td.appendChild(document.createTextNode(' '));
      sym = document.createElement("span");
      sym.style.color = this.get_colour(this.get_index(equals[j]));
      sym.appendChild(document.createTextNode(equals[j]));
      td.appendChild(sym);
    }
    row.appendChild(td);
  }
  return table;
};

// returns a dictionary of the colours for EPS
Alphabet.prototype._as_eps_dict = function() {
  "use strict";
  var i, sym, rgb;
  var out = "/fullColourDict <<\n";
  for (i = 0; i < this.ncore; i++) {
    sym = this.get_symbol(i);
    sym = sym.replace(/\\/g, "\\\\");
    sym = sym.replace(/\(/g, "\\(");
    sym = sym.replace(/\)/g, "\\)");
    rgb = this.get_rgb(i);
    out += " (" + sym + ") [" + rgb.red.toFixed(4) + " " + rgb.green.toFixed(4) + " " + rgb.blue.toFixed(4) + "]\n";
  }
  out += ">> def\n";
  out += "/mutedColourDict <<\n";
  for (i = 0; i < this.ncore; i++) {
    sym = this.get_symbol(i);
    sym = sym.replace(/\\/g, "\\\\");
    sym = sym.replace(/\(/g, "\\(");
    sym = sym.replace(/\)/g, "\\)");
    rgb = Alphabet.lighten_colour(this.get_rgb(i));
    out += " (" + sym + ") [" + rgb.red.toFixed(4) + " " + rgb.green.toFixed(4) + " " + rgb.blue.toFixed(4) + "]\n";
  }
  out += ">> def\n";
  return out;
};

// return the alphabet name or a list of primary symbols
Alphabet.prototype.toString = function() {
  "use strict";
  if (this.name != null) {
    return this.name;
  } else {
    return this.get_symbols();
  }
};

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Helper functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// Convert a colour specified in RGB colourspace values into LAB colourspace
Alphabet.rgb2lab = function(rgb) {
  "use strict";
  var xyzHelper, labHelper;
  // XYZ helper
  xyzHelper = function(value) {
    if (value > 0.0445) {
      value = (value + 0.055) / 1.055;
      value = Math.pow(value, 2.4);
    } else {
      value /= 12.92;
    }
    value *= 100;
    return value;
  };
  // lab helper
  labHelper = function(value) {
    if (value > 0.008856) {
      value = Math.pow(value, 1.0 / 3.0);
    } else {
      value = (7.787 * value) + (16.0 / 116.0);
    }
    return value;
  };
  // convert into XYZ colourspace
  var c1, c2, c3;
  if (typeof rgb == "number") {
    c1 = xyzHelper(((rgb >> 16) & 0xFF) / 255.0);
    c2 = xyzHelper(((rgb >> 8) & 0xFF) / 255.0);
    c3 = xyzHelper((rgb & 0xFF) / 255.0);
  } else {
    c1 = xyzHelper(rgb.red);
    c2 = xyzHelper(rgb.green);
    c3 = xyzHelper(rgb.blue);
  }
  var x = (c1 * 0.4124) + (c2 * 0.3576) + (c3 * 0.1805);
  var y = (c1 * 0.2126) + (c2 * 0.7152) + (c3 * 0.0722);
  var z = (c1 * 0.0193) + (c2 * 0.1192) + (c3 * 0.9505);
  // convert into Lab colourspace
  c1 = labHelper(x / 95.047);
  c2 = labHelper(y / 100.0);
  c3 = labHelper(z / 108.883);
  var l = (116.0 * c2) - 16;
  var a = 500.0 * (c1 - c2);
  var b = 200.0 * (c2 - c3);
  return {"l": l, "a": a, "b": b};
};

// Convert a colour specified in HSV colourspace into RGB colourspace
Alphabet.hsv2rgb = function(hue, sat, value, output_object) {
  // achromatic (grey)
  var r = value;
  var g = value;
  var b = value;
  if (sat != 0) {
    var h = hue / 60.0;
    var i = Math.floor(h);
    var f = h - i;
    var p = value * (1.0 - sat);
    var q = value * (1.0 - (sat * f));
    var t = value * (1.0 - (sat * (1.0 - f)));
    if (i == 0) {
      r = value;
      g = t;
      b = p;
    } else if (i == 1) {
      r = q;
      g = value;
      b = p;
    } else if (i == 2) {
      r = p;
      g = value;
      b = t;
    } else if (i == 3) {
      r = p;
      g = q;
      b = value;
    } else if (i == 4) {
      r = t;
      g = p;
      b = value;
    } else {
      r = value;
      g = p;
      b = q;
    }
  }
  if (output_object) {
    return {"red": r, "green": g, "blue": b};
  } else {
    return (Math.floor(r * 255) << 15) | (Math.floor(g * 255) << 8) | (Math.floor(b * 255));
  }
};

// Calculate a distance score between two colours in LAB colourspace
Alphabet.lab_dist = function(lab1, lab2) {
  var c1 = Math.sqrt((lab1.l * lab1.l) + (lab1.a * lab1.a));
  var c2 = Math.sqrt((lab2.l * lab2.l) + (lab2.a * lab2.a));
  var dc = c1 - c2;
  var dl = lab1.l - lab2.l;
  var da = lab1.a - lab2.a;
  var db = lab1.b - lab2.b;
  // we don't want NaN due to rounding errors so fudge things a bit...
  var dh = 0;
  var dh_squared = (da * da) + (db * db) - (dc * dc);
  if (dh_squared > 0) {
    dh = Math.sqrt(dh_squared);
  }
  var first = dl;
  var second = dc / (1.0 + (0.045 * c1));
  var third = dh / (1.0 + (0.015 * c1));
  return Math.sqrt((first * first) + (second * second) + (third * third));
};

// convert an RGB value into a HSL value
Alphabet.rgb2hsl = function(rgb) {
  "use strict";
  var min, max, delta, h, s, l, r, g, b;
  if (typeof rgb == "number") {
    r = ((rgb >> 16) & 0xFF) / 255.0;
    g = ((rgb >> 8) & 0xFF) / 255.0;
    b = (rgb & 0xFF) / 255.0;
  } else {
    r = rgb.red;
    g = rgb.green;
    b = rgb.blue;
  }
  min = Math.min(r, g, b);
  max = Math.max(r, g, b);
  delta = max - min;
  l = min + (delta / 2);
  if (max == min) {
    h = 0; // achromatic (grayscale)
    s = 0;
  } else {
    if (l > 0.5) {
      s = delta / (2 - max - min);
    } else {
      s = delta / (max + min);
    }
    if (max == r) {
      h = (g - b) / delta;
      if (g < b) h += 6;
    } else if (max == g) {
      h = ((b - r) / delta) + 2;
    } else {
      h = ((r - g) / delta) + 4;
    }
    h /= 6;
  }
  return {"h": h, "s": s, "l": l};
};

// convert a HSL value into an RGB value
Alphabet.hsl2rgb = function(hsl, output_object) {
  "use strict";
  function _hue(p, q, t) {
    "use strict";
    if (t < 0) t += 1;
    else if (t > 1) t -= 1;
    if (t < (1.0 / 6.0)) {
      return p + ((q - p) * 6.0 * t);
    } else if (t < 0.5) {
      return q;
    } else if (t < (2.0 / 3.0)) {
      return p + ((q - p) * ((2.0 / 3.0) - t) * 6.0);
    } else {
      return p;
    }
  }
  var r, g, b, p, q;
  if (hsl.s == 0) {
    // achromatic (grayscale)
    r = hsl.l;
    g = hsl.l;
    b = hsl.l;
  } else {
    if (hsl.l < 0.5) {
      q = hsl.l * (1 + hsl.s);
    } else {
      q = hsl.l + hsl.s - (hsl.l * hsl.s);
    }
    p = (2 * hsl.l) - q;
    r = _hue(p, q, hsl.h + (1.0 / 3.0));
    g = _hue(p, q, hsl.h);
    b = _hue(p, q, hsl.h - (1.0 / 3.0));
  }
  if (output_object) {
    return {"red": r, "green": g, "blue": b};
  } else {
    return (Math.floor(r * 255) << 15) | (Math.floor(g * 255) << 8) | (Math.floor(b * 255));
  }
};

Alphabet.lighten_colour = function(rgb) {
  "use strict";
  var hsl = Alphabet.rgb2hsl(rgb);
  hsl.l += (1.0 - hsl.l) * 2 / 3;
  return Alphabet.hsl2rgb(hsl, typeof rgb != "number");
};

//======================================================================
// end Alphabet object
//======================================================================

//======================================================================
// start StandardAlphabet object
//======================================================================

// an extension of the alphabet object to support some additional fields 
// only present in standard alphabets.
var StandardAlphabet = function(enum_code, enum_name, alphabet_data) {
  Alphabet.apply(this, [alphabet_data]);
  this.enum_code = enum_code;
  this.enum_name = enum_name;
};
StandardAlphabet.prototype = Alphabet.prototype;
StandardAlphabet.prototype.constructor = StandardAlphabet;

// A unique code for this standard alphabet.
// This code will be a power of 2 to enable creation of bitsets for
// a selection of standard alphabets.
StandardAlphabet.prototype.get_code = function() {
  return this.enum_code;
};

// A unique name for this standard alphabet.
// this name will be all upper case and the same as the property that
// refers to this alphabet in the AlphStd collection.
StandardAlphabet.prototype.get_enum = function() {
  return this.enum_name;
};

//======================================================================
// end StandardAlphabet object
//======================================================================

// A collection of standard alphabets.
var AlphStd = {
  RNA: new StandardAlphabet(1, "RNA", {
    "name": "RNA",
    "like": "RNA",
    "ncore": 4,
    "symbols": [
      {"symbol": "A", "name": "Adenine", "colour": "CC0000"},
      {"symbol": "C", "name": "Cytosine", "colour": "0000CC"},
      {"symbol": "G", "name": "Guanine", "colour": "FFB300"},
      {"symbol": "U", "name": "Uracil", "colour": "008000",
        "aliases": "T"},
      {"symbol": "N", "name": "Any base", "equals": "ACGU", "aliases": "X."},
      {"symbol": "V", "name": "Not U", "equals": "ACG"},
      {"symbol": "H", "name": "Not G", "equals": "ACU"},
      {"symbol": "D", "name": "Not C", "equals": "AGU"},
      {"symbol": "B", "name": "Not A", "equals": "CGU"},
      {"symbol": "M", "name": "Amino", "equals": "AC"},
      {"symbol": "R", "name": "Purine", "equals": "AG"},
      {"symbol": "W", "name": "Weak", "equals": "AU"}, 
      {"symbol": "S", "name": "Strong", "equals": "CG"},
      {"symbol": "Y", "name": "Pyrimidine", "equals": "CU"},
      {"symbol": "K", "name": "Keto", "equals": "GU"}
    ]
  }), 
  DNA: new StandardAlphabet(2, "DNA", {
    "name": "DNA",
    "like": "DNA",
    "ncore": 4,
    "symbols": [
      {"symbol": "A", "name": "Adenine", "colour": "CC0000", "complement": "T"},
      {"symbol": "C", "name": "Cytosine", "colour": "0000CC", "complement": "G"},
      {"symbol": "G", "name": "Guanine", "colour": "FFB300", "complement": "C"},
      {"symbol": "T", "name": "Thymine", "colour": "008000", "complement": "A",
        "aliases": "U"},
      {"symbol": "N", "name": "Any base", "equals": "ACGT", "aliases": "X."},
      {"symbol": "V", "name": "Not T", "equals": "ACG"},
      {"symbol": "H", "name": "Not G", "equals": "ACT"},
      {"symbol": "D", "name": "Not C", "equals": "AGT"},
      {"symbol": "B", "name": "Not A", "equals": "CGT"},
      {"symbol": "M", "name": "Amino", "equals": "AC"},
      {"symbol": "R", "name": "Purine", "equals": "AG"},
      {"symbol": "W", "name": "Weak", "equals": "AT"}, 
      {"symbol": "S", "name": "Strong", "equals": "CG"},
      {"symbol": "Y", "name": "Pyrimidine", "equals": "CT"},
      {"symbol": "K", "name": "Keto", "equals": "GT"}
    ]
  }), 
  PROTEIN: new StandardAlphabet(4, "PROTEIN", {
    "name": "Protein",
    "like": "PROTEIN",
    "ncore": 20,
    "symbols": [
      {"symbol": "A", "name": "Alanine", "colour": "0000CC"},
      {"symbol": "C", "name": "Cysteine", "colour": "0000CC"},
      {"symbol": "D", "name": "Aspartic acid", "colour": "FF00FF"},
      {"symbol": "E", "name": "Glutamic acid", "colour": "FF00FF"},
      {"symbol": "F", "name": "Phenylalanine", "colour": "0000CC"},
      {"symbol": "G", "name": "Glycine", "colour": "FFB300"},
      {"symbol": "H", "name": "Histidine", "colour": "FFCCCC"},
      {"symbol": "I", "name": "Isoleucine", "colour": "0000CC"},
      {"symbol": "K", "name": "Lysine", "colour": "CC0000"},
      {"symbol": "L", "name": "Leucine", "colour": "0000CC"},
      {"symbol": "M", "name": "Methionine", "colour": "0000CC"},
      {"symbol": "N", "name": "Asparagine", "colour": "008000"},
      {"symbol": "P", "name": "Proline", "colour": "FFFF00"},
      {"symbol": "Q", "name": "Glutamine", "colour": "008000"},
      {"symbol": "R", "name": "Arginine", "colour": "CC0000"},
      {"symbol": "S", "name": "Serine", "colour": "008000"},
      {"symbol": "T", "name": "Threonine", "colour": "008000"},
      {"symbol": "V", "name": "Valine", "colour": "0000CC"},
      {"symbol": "W", "name": "Tryptophan", "colour": "0000CC"},
      {"symbol": "Y", "name": "Tyrosine", "colour": "33E6CC"},
      {"symbol": "X", "name": "Any amino acid", "equals": "ACDEFGHIKLMNPQRSTVWY", "aliases": "*."},
      {"symbol": "B", "name": "Asparagine or Aspartic acid", "equals": "DN"}, 
      {"symbol": "Z", "name": "Glutamine or Glutamic acid", "equals": "EQ"}, 
      {"symbol": "J", "name": "Leucine or Isoleucine", "equals": "IL"}
    ]
  })
};

//======================================================================
// start Symbol object
//======================================================================
var Symbol = function(alph_index, scale, alphabet) {
  "use strict";
  //variable prototype
  this.symbol = alphabet.get_symbol(alph_index);
  this.scale = scale;
  this.colour = alphabet.get_colour(alph_index);
};

Symbol.prototype.get_symbol = function() {
  "use strict";
  return this.symbol;
};

Symbol.prototype.get_scale = function() {
  "use strict";
  return this.scale;
};

Symbol.prototype.get_colour = function() {
  "use strict";
  return this.colour;
};

Symbol.prototype.toString = function() {
  "use strict";
  return this.symbol + " " + (Math.round(this.scale*1000)/10) + "%";
};

function compare_symbol(sym1, sym2) {
  "use strict";
  if (sym1.get_scale() < sym2.get_scale()) {
    return -1;
  } else if (sym1.get_scale() > sym2.get_scale()) {
    return 1;
  } else {
    return 0;
  }
}
//======================================================================
// end Symbol object
//======================================================================

//======================================================================
// start Pspm object
//======================================================================
var Pspm = function(matrix, name, ltrim, rtrim, nsites, evalue, pssm, alt) {
  "use strict";
  var row, col, data, row_sum, delta, evalue_re;
  if (typeof name !== "string") {
    name = "";
  }
  this.name = name;
  //construct
  if (matrix instanceof Pspm) {
    // copy constructor
    this.alph_length = matrix.alph_length;
    this.motif_length = matrix.motif_length;
    this.name = matrix.name;
    this.alt = matrix.alt;
    this.nsites = matrix.nsites;
    this.evalue = matrix.evalue;
    this.ltrim = matrix.ltrim;
    this.rtrim = matrix.rtrim;
    this.pspm = [];
    for (row = 0; row < matrix.motif_length; row++) {
      this.pspm[row] = [];
      for (col = 0; col < matrix.alph_length; col++) {
        this.pspm[row][col] = matrix.pspm[row][col];
      }
    }
    if (matrix.pssm != null) {
      this.pssm = [];
      for (row = 0; row < matrix.motif_length; row++) {
        this.pspm[row] = [];
        for (col = 0; col < matrix.alph_length; col++) {
          this.pssm[row][col] = matrix.pssm[row][col];
        }
      }
    }
  } else {
    // check parameters
    if (ltrim == null) {
      ltrim = 0;
    } else if (typeof ltrim !== "number" || ltrim % 1 !== 0 || ltrim < 0) {
      throw new Error("ltrim must be a non-negative integer, got: " + ltrim);
    }
    if (rtrim == null) {
      rtrim = 0;
    } else if (typeof rtrim !== "number" || rtrim % 1 !== 0 || rtrim < 0) {
      throw new Error("rtrim must be a non-negative integer, got: " + rtrim);
    }
    if (nsites != null) {
      if (typeof nsites !== "number" || nsites < 0) {
        throw new Error("nsites must be a positive number, got: " + nsites);
      } else if (nsites == 0) {
        nsites = null;
      }
    }
    if (evalue != null) {
      if (typeof evalue === "number") {
        if (evalue < 0) {
          throw new Error("evalue must be a non-negative number, got: " + evalue);
        }
      } else if (typeof evalue === "string") {
        evalue_re = /^((?:[+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?)|inf)$/;
        if (!evalue_re.test(evalue)) {
          throw new Error("evalue must be a non-negative number, got: " + evalue);
        }
      } else {
        throw new Error("evalue must be a non-negative number, got: " + evalue);
      }
    }
    // set properties
    this.name = name;
    this.alt = alt;
    this.nsites = nsites;
    this.evalue = evalue;
    this.ltrim = ltrim;
    this.rtrim = rtrim;
    if (typeof matrix === "string") {
      // string constructor
      data = parse_pspm_string(matrix);
      this.alph_length = data["alph_length"];
      this.motif_length = data["motif_length"];
      this.pspm = data["pspm"];
      if (this.evalue == null) {
        if (data["evalue"] != null) {
          this.evalue = data["evalue"];
        } else {
          this.evalue = 0;
        }
      }
      if (this.nsites == null) {
        if (typeof data["nsites"] === "number") {
          this.nsites = data["nsites"];
        } else {
          this.nsites = 20;
        }
      }
    } else {
      // assume pspm is a nested array
      this.motif_length = matrix.length;
      this.alph_length = (matrix.length > 0 ? matrix[0].length : 0);
      if (this.nsites == null) {
        this.nsites = 20;
      }
      if (this.evalue == null) {
        this.evalue = 0;
      }
      this.pspm = [];
      // copy pspm and check
      for (row = 0; row < this.motif_length; row++) {
        if (this.alph_length != matrix[row].length) {
          throw new Error("COLUMN_MISMATCH");
        }
        this.pspm[row] = [];
        row_sum = 0;
        for (col = 0; col < this.alph_length; col++) {
          this.pspm[row][col] = matrix[row][col];
          row_sum += this.pspm[row][col];
        }
        delta = 0.1;
        if (isNaN(row_sum) || (row_sum > 1 && (row_sum - 1) > delta) || 
            (row_sum < 1 && (1 - row_sum) > delta)) {
          throw new Error("INVALID_SUM");
        }
      }
      // copy pssm
      if (pssm != null) {
        this.pssm = [];
        for (row = 0; row < this.motif_length; row++) {
          this.pssm[row] = [];
          for (col = 0; col < this.alph_length; col++) {
            this.pssm[row][col] = pssm[row][col];
          }
        }
      }
    }
  }
};

Pspm.prototype.copy = function() {
  "use strict";
  return new Pspm(this);
};

Pspm.prototype.reverse = function() {
  "use strict";
  var x, y, temp, temp_trim;
  //reverse
  x = 0;
  y = this.motif_length-1;
  while (x < y) {
    temp = this.pspm[x];
    this.pspm[x] = this.pspm[y];
    this.pspm[y] = temp;
    x++;
    y--;
  }
  // reverse pssm (if defined)
  if (typeof this.pssm !== "undefined") {
    //reverse
    x = 0;
    y = this.motif_length-1;
    while (x < y) {
      temp = this.pssm[x];
      this.pspm[x] = this.pssm[y];
      this.pssm[y] = temp;
      x++;
      y--;
    }
  }
  //swap triming
  temp_trim = this.ltrim;
  this.ltrim = this.rtrim;
  this.rtrim = temp_trim;
  return this; //allow function chaining...
};

Pspm.prototype.reverse_complement = function(alphabet) {
  "use strict";
  var x, y, temp, i, row, c, temp_trim;
  if (this.alph_length != alphabet.get_size_core()) {
    throw new Error("The alphabet size does not match the size of the pspm.");
  }
  if (!alphabet.has_complement()) {
    throw new Error("The specified alphabet can not be complemented.");
  }
  // reverse motif
  this.reverse();
  //complement
  for (x = 0; x < this.motif_length; x++) {
    row = this.pspm[x];
    for (i = 0; i < row.length; i++) {
      c = alphabet.get_complement(i);
      if (c < i) continue;
      temp = row[i];
      row[i] = row[c];
      row[c] = temp;
    }
  }
  // complement pssm (if defined)
  if (typeof this.pssm !== "undefined") {
    //complement
    for (x = 0; x < this.motif_length; x++) {
      row = this.pssm[x];
      for (i = 0; i < row.length; i++) {
        c = alphabet.get_complement(i);
        if (c < i) continue;
        temp = row[i];
        row[i] = row[c];
        row[c] = temp;
      }
    }
  }
  return this; //allow function chaining...
};

Pspm.prototype.get_stack = function(position, alphabet, ssc) {
  "use strict";
  var row, stack_ic, alphabet_ic, stack, i, sym;
  if (this.alph_length != alphabet.get_size_core()) {
    throw new Error("The alphabet size does not match the size of the pspm.");
  }
  row = this.pspm[position];
  stack_ic = this.get_stack_ic(position, alphabet);
  if (ssc) stack_ic -= this.get_error(alphabet);
  alphabet_ic = alphabet.get_ic();
  stack = [];
  for (i = 0; i < this.alph_length; i++) {
    sym = new Symbol(i, row[i]*stack_ic/alphabet_ic, alphabet);
    if (sym.get_scale() <= 0) {
      continue;
    }
    stack.push(sym);
  }
  stack.sort(compare_symbol);
  return stack;
};

Pspm.prototype.get_stack_ic = function(position, alphabet) {
  "use strict";
  var row, H, i;
  if (this.alph_length != alphabet.get_size_core()) {
    throw new Error("The alphabet size does not match the size fo the pspm.");
  }
  row = this.pspm[position];
  H = 0;
  for (i = 0; i < this.alph_length; i++) {
    if (row[i] === 0) {
      continue;
    }
    H -= (row[i] * (Math.log(row[i]) / Math.LN2));
  }
  return alphabet.get_ic() - H;
};

Pspm.prototype.get_error = function(alphabet) {
  "use strict";
  if (this.nsites === 0) {
    return 0;
  }
  return (alphabet.get_size_core()-1) / (2 * Math.LN2 * this.nsites);
};

Pspm.prototype.get_motif_length = function() {
  "use strict";
  return this.motif_length;
};

Pspm.prototype.get_alph_length = function() {
  "use strict";
  return this.alph_length;
};

Pspm.prototype.get_left_trim = function() {
  "use strict";
  return this.ltrim;
};

Pspm.prototype.get_right_trim = function() {
  "use strict";
  return this.rtrim;
};

Pspm.prototype.as_best_match = function(alphabet) {
  "use strict";
  var match, odds, best_odds, best_index;
  var i, j;
  match = "";
  for (i = 0; i < this.motif_length; i++) {
    best_index = 0;
    best_odds = this.pspm[i][0] / alphabet.get_bg_freq(0);
    for (j = 1; j < this.alph_length; j++) {
      odds = this.pspm[i][j] / alphabet.get_bg_freq(j);
      if (odds > best_odds) {
        best_odds = odds;
        best_index = j;
      }
    }
    match += alphabet.get_symbol(best_index);
  }
  return match;
};

Pspm.prototype.as_count_matrix = function() {
  "use strict";
  var count, count_text, text;
  var i, j;
  text = "";
  for (i = 0; i < this.motif_length; i++) {
    if (i !== 0) {
      text += "\n";
    }
    for (j = 0; j < this.alph_length; j++) {
      if (j !== 0) {
        text += " ";
      }
      count = Math.round(this.nsites * this.pspm[i][j]);
      count_text = "" + count;
      // pad up to length of 4
      if (count_text.length < 4) {
        text += (new Array(5 - count_text.length)).join(" ") + count_text;
      } else {
        text += count_text;
      }
    }
  }
  return text; 
};

Pspm.prototype.as_probability_matrix = function() {
  "use strict";
  var text;
  var i, j;
  text = "";
  for (i = 0; i < this.motif_length; i++) {
    if (i !== 0) {
      text += "\n";
    }
    for (j = 0; j < this.alph_length; j++) {
      if (j !== 0) {
        text += " ";
      }
      text += this.pspm[i][j].toFixed(6);
    }
  }
  return text; 
};

Pspm.prototype.as_score_matrix = function(alphabet, pseudo) {
  "use strict";
  var me, score, out, row, col, score_text;
  me = this;
  if (typeof this.pssm === "undefined") {
    if (!(typeof alphabet === "object" && alphabet != null && alphabet instanceof Alphabet)) {
      throw new Error("The alphabet is required to generate the pssm.");
    }
    if (typeof pseudo === "undefined") {
      pseudo = 0.01;
    } else if (typeof pseudo !== "number" || pseudo < 0) {
      throw new Error("Expected positive number for pseudocount");
    }
    score = function(row, col) {
      "use strict";
      var p, bg, p2;
      p = me.pspm[row][col];
      bg = alphabet.get_bg_freq(col);
      p2 = (p * me.nsites + bg * pseudo) / (me.nsites + pseudo);
      return (p2 > 0 ? Math.round((Math.log(p2 / bg) / Math.LN2) * 100) : -10000);
    };
  } else {
    score = function(row, col) {
      "use strict";
      return me.pssm[row][col];
    };
  }
  out = "";
  for (row = 0; row < this.motif_length; row++) {
    for (col = 0; col < this.alph_length; col++) {
      if (col !== 0) {
        out += " ";
      }
      score_text = "" + score(row, col);
      // pad out to 6 characters
      if (score_text.length < 6) {
        out += (new Array(7 - score_text.length)).join(" ") + score_text;
      } else {
        out += score_text;
      }
    }
    out += "\n";
  }
  return out;
}

Pspm.prototype.as_pspm = function() {
  "use strict";
  return "letter-probability matrix: alength= " + this.alph_length + 
      " w= " + this.motif_length + " nsites= " + this.nsites + 
      " E= " + (typeof this.evalue === "number" ? 
          this.evalue.toExponential() : this.evalue) + "\n" +
      this.as_probability_matrix();
};

Pspm.prototype.as_pssm = function(alphabet, pseudo) {
  "use strict";
  return "log-odds matrix: alength= " + this.alph_length + 
      " w= " + this.motif_length + 
      " E= " + (typeof this.evalue == "number" ?
          this.evalue.toExponential() : this.evalue) + "\n" +
      this.as_score_matrix(alphabet, pseudo);
};

Pspm.prototype.as_meme = function(options) {
  var with_header, with_pspm, with_pssm, version, alphabet, bg_source, pseudocount, strands;
  var out, alen, i;
  // get the options
  if (typeof options !== "object" || options === null) {
    options = {};
  }
  with_header = (typeof options["with_header"] === "boolean" ? options["with_header"] : false);
  with_pspm = (typeof options["with_pspm"] === "boolean" ? options["with_pspm"] : false);
  with_pssm = (typeof options["with_pssm"] === "boolean" ? options["with_pssm"] : false);
  if (!with_pspm && !with_pssm) with_pspm = true;
  if (with_header) {
    if (typeof options["version"] === "string" && /^\d+(?:\.\d+){0,2}$/.test(options["version"])) {
      version = options["version"];
    } else if (typeof options["version"] === "number") {
      version = options["version"].toFixed(0);
    } else {
      version = "4";
    }
    if (typeof options["strands"] === "number" && options["strands"] === 1) {
      strands = 1;
    } else {
      strands = 2;
    }
    if (typeof options["bg_source"] === "string") {
      bg_source = options["bg_source"];
    } else {
      bg_source = "unknown source";
    }
    if (typeof options["alphabet"] === "object" && options["alphabet"] != null
        && options["alphabet"] instanceof Alphabet) {
      alphabet = options["alphabet"];
    } else {
      throw new Error("The alphabet is required to generate the header.");
    }
  }
  // now create the output
  out = "";
  if (with_header) {
    out = "MEME version " + version + "\n\n";
    out += alphabet.as_meme() + "\n";
    if (alphabet.has_complement()) { // assume DNA has both strands unless otherwise specified
      out += "strands: " + (strands === 1 ? "+" : "+ -") + "\n\n";
    }
    out += "Background letter frequencies (from " + bg_source + "):\n";
    alen = alphabet.get_size_core();
    for (i = 0; i < alen; i++) {
      if (i !== 0) {
        if (i % 9 === 0) { // maximum of nine entries per line
          out += "\n";
        } else {
          out += " ";
        }
      }
      out += alphabet.get_symbol(i) + " " + alphabet.get_bg_freq(i).toFixed(3);
    }
  }
  out += "\n\n";
  out += "MOTIF " + this.name + (this.alt == null ? "" : " " + this.alt);
  if (with_pssm) {
    out += "\n\n";
    out += this.as_pssm(options["alphabet"], options["pseudocount"]);
  }
  if (with_pspm) {
    out += "\n\n";
    out += this.as_pspm();
  }
  return out;
}

Pspm.prototype.toString = function() {
  "use strict";
  var str, i, row;
  str = "";
  for (i = 0; i < this.pspm.length; i++) {
    row = this.pspm[i];
    str += row.join("\t") + "\n";
  }
  return str;
};

function parse_pspm_properties(str) {
  "use strict";
  var parts, i, eqpos, before, after, properties, prop, num, num_re;
  num_re = /^((?:[+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?)|inf)$/;
  parts = trim(str).split(/\s+/);
  // split up words containing =
  for (i = 0; i < parts.length;) {
    eqpos = parts[i].indexOf("=");
    if (eqpos != -1) {
      before = parts[i].substr(0, eqpos);
      after = parts[i].substr(eqpos+1);
      if (before.length > 0 && after.length > 0) {
        parts.splice(i, 1, before, "=", after);
        i += 3;
      } else if (before.length > 0) {
        parts.splice(i, 1, before, "=");
        i += 2;
      } else if (after.length > 0) {
        parts.splice(i, 1, "=", after);
        i += 2;
      } else {
        parts.splice(i, 1, "=");
        i++;
      }
    } else {
      i++;
    }
  }
  properties = {};
  for (i = 0; i < parts.length; i += 3) {
    if (parts.length - i < 3) {
      throw new Error("Expected PSPM property was incomplete. "+
          "Remaing parts are: " + parts.slice(i).join(" "));
    }
    if (parts[i+1] !== "=") {
      throw new Error("Expected '=' in PSPM property between key and " +
          "value but got " + parts[i+1]); 
    }
    prop = parts[i].toLowerCase();
    num = parts[i+2];
    if (!num_re.test(num)) {
      throw new Error("Expected numeric value for PSPM property '" + 
          prop + "' but got '" + num + "'");
    }
    properties[prop] = num;
  }
  return properties;
}

function parse_pspm_string(pspm_string) {
  "use strict";
  var header_re, lines, first_line, line_num, col_num, alph_length, 
      motif_length, nsites, evalue, pspm, i, line, match, props, parts,
      j, prob;
  header_re = /^letter-probability\s+matrix:(.*)$/i;
  lines = pspm_string.split(/\n/);
  first_line = true;
  line_num = 0;
  col_num = 0;
  alph_length;
  motif_length;
  nsites;
  evalue;
  pspm = [];
  for (i = 0; i < lines.length; i++) {
    line = trim(lines[i]);
    if (line.length === 0) { 
      continue;
    }
    // check the first line for a header though allow matrices without it
    if (first_line) {
      first_line = false;
      match = header_re.exec(line);
      if (match !== null) {
        props = parse_pspm_properties(match[1]);
        if (props.hasOwnProperty("alength")) {
          alph_length = parseFloat(props["alength"]);
          if (alph_length != 4 && alph_length != 20) {
            throw new Error("PSPM property alength should be 4 or 20" +
                " but got " + alph_length);
          }
        }
        if (props.hasOwnProperty("w")) {
          motif_length = parseFloat(props["w"]);
          if (motif_length % 1 !== 0 || motif_length < 1) {
            throw new Error("PSPM property w should be an integer larger " +
                "than zero but got " + motif_length);
          }
        }
        if (props.hasOwnProperty("nsites")) {
          nsites = parseFloat(props["nsites"]);
          if (nsites <= 0) {
            throw new Error("PSPM property nsites should be larger than " +
                "zero but got " + nsites);
          }
        }
        if (props.hasOwnProperty("e")) {
          evalue = props["e"];
          if (evalue < 0) {
            throw new Error("PSPM property evalue should be " +
                "non-negative but got " + evalue);
          }
        }
        continue;
      }
    }
    pspm[line_num] = [];
    col_num = 0;
    parts = line.split(/\s+/);
    for (j = 0; j < parts.length; j++) {
      prob = parseFloat(parts[j]);
      if (prob != parts[j] || prob < 0 || prob > 1) {
        throw new Error("Expected probability but got '" + parts[j] + "'"); 
      }
      pspm[line_num][col_num] = prob;
      col_num++;
    }
    line_num++;
  }
  if (typeof motif_length === "number") {
    if (pspm.length != motif_length) {
      throw new Error("Expected PSPM to have a motif length of " + 
          motif_length + " but it was actually " + pspm.length);
    }
  } else {
    motif_length = pspm.length;
  }
  if (typeof alph_length !== "number") {
    alph_length = pspm[0].length;
    if (alph_length != 4 && alph_length != 20) {
      throw new Error("Expected length of first row in the PSPM to be " +
          "either 4 or 20 but got " + alph_length);
    }
  }
  for (i = 0; i < pspm.length; i++) {
    if (pspm[i].length != alph_length) {
      throw new Error("Expected PSPM row " + i + " to have a length of " + 
          alph_length + " but the length was " + pspm[i].length);
    }
  }
  return {"pspm": pspm, "motif_length": motif_length, 
    "alph_length": alph_length, "nsites": nsites, "evalue": evalue};
}
//======================================================================
// end Pspm object
//======================================================================

//======================================================================
// start Logo object
//======================================================================

var Logo = function(alphabet, options) {
  "use strict";
  this.alphabet = alphabet;
  this.fine_text = "";
  this.x_axis = 1;
  this.y_axis = true;
  this.xlate_nsyms = 1;
  this.xlate_start = null;
  this.xlate_end = null;
  this.pspm_list = [];
  this.pspm_column = [];
  this.rows = 0;
  this.columns = 0;
  if (typeof options === "string") {
    // the old method signature had fine_text here so we support that
    this.fine_text = options;
  } else if (typeof options === "object" && options != null) {
    this.fine_text = (typeof options.fine_text === "string" ? options.fine_text : "");
    this.x_axis = (typeof options.x_axis === "boolean" ? (options.x_axis ? 1 : 0) : 1);
    if (options.x_axis_hidden != null && options.x_axis_hidden) this.x_axis = -1;
    this.y_axis = (typeof options.y_axis === "boolean" ? options.y_axis : true);
    this.xlate_nsyms = (typeof options.xlate_nsyms === "number" ? options.xlate_nsyms : this.xlate_nsyms);
    this.xlate_start = (typeof options.xlate_start === "number" ? options.xlate_start : this.xlate_start);
    this.xlate_end = (typeof options.xlate_end === "number" ? options.xlate_end : this.xlate_end);
  }
};

Logo.prototype.add_pspm = function(pspm, column) {
  "use strict";
  var col;
  if (typeof column === "undefined") {
    column = 0;
  } else if (column < 0) {
    throw new Error("Column index out of bounds.");
  }
  this.pspm_list[this.rows] = pspm;
  this.pspm_column[this.rows] = column;
  this.rows++;
  col = column + pspm.get_motif_length();
  if (col > this.columns) {
    this.columns = col;
  }
};

Logo.prototype.get_columns = function() {
  "use strict";
  return this.columns;
};

Logo.prototype.get_xlate_nsyms = function() {
  "use strict";
  return this.xlate_nsyms;
};

Logo.prototype.get_xlate_start = function() {
  "use strict";
  return (this.xlate_start != null ? this.xlate_start : 0);
};

Logo.prototype.get_xlate_end = function() {
  "use strict";
  return (this.xlate_end != null ? this.xlate_end : this.columns * this.xlate_nsyms);
};

Logo.prototype.get_xlate_columns = function() {
  "use strict";
  return this.get_xlate_end() - this.get_xlate_start();
};

Logo.prototype.get_rows = function() {
  "use strict";
  return this.rows;
};

Logo.prototype.get_pspm = function(row_index) {
  "use strict";
  if (row_index < 0 || row_index >= this.rows) {
    throw new Error("INDEX_OUT_OF_BOUNDS");
  }
  return this.pspm_list[row_index];
};

Logo.prototype.get_offset = function(row_index) {
  "use strict";
  if (row_index < 0 || row_index >= this.rows) {
    throw new Error("INDEX_OUT_OF_BOUNDS");
  }
  return this.pspm_column[row_index];
};

Logo.prototype._as_eps_data = function(ssc, errbars) {
  var i, j, pos, stack_pos, pspm, stack, sym, out;
  out = "";
  for (i = 0; i < this.rows; i++) {
    out += "\nStartLine\n";
    // Indent
    for (j = 0; j < this.pspm_column[i]; j++) {
      out += "() startstack\nendstack\n\n";
    }
    pspm = this.pspm_list[i];
    if (pspm.get_left_trim() > 0) {
      out += "MuteColour\nDrawTrimEdge\n" + pspm.get_left_trim() + " DrawTrimBg\n";
    }
    for (pos = 0; pos < pspm.get_motif_length(); pos++) {
      if (pos != 0 && pos == pspm.get_left_trim()) { // enable full colour
        out += "DrawTrimEdge\nRestoreColour\n";
      } else if (pos == (pspm.get_motif_length() - pspm.get_right_trim())) {
        out += "MuteColour\n" + pspm.get_right_trim() + " DrawTrimBg\n";
      }
      out += "(" + (pos + 1) + ") startstack\n";
      stack = pspm.get_stack(pos, this.alphabet, ssc);
      for (stack_pos = 0; stack_pos < stack.length; stack_pos++) {
        sym = stack[stack_pos];
        out += " " + (sym.get_scale() * this.alphabet.get_ic()) + " (" + sym.get_symbol() + ") numchar\n";
      }
      if (errbars) {
        out += " " + pspm.get_error(this.alphabet) + " Ibeam\n";
      }
      out += "endstack\n\n";
    }
    if (pspm.get_right_trim() > 0 || pspm.get_left_trim() == pspm.get_motif_length()) {
      out += "RestoreColour\n";
    }
    out += "EndLine\n";
  }
  return out;
};

Logo.prototype.as_eps = function(options) {
  "use strict";
  if (this.xlate_nsyms != 1) throw new Error("Unsupported setting xlate_nsyms for EPS");
  if (this.xlate_start != null) throw new Error("Unsupported setting xlate_start for EPS");
  if (this.xlate_end != null) throw new Error("Unsupported setting xlate_end for EPS");

  var LOGOHEIGHT = 7.5; // default height of line in cm
  var cm2pts, height, width, now, ssc, errbars;
  if (typeof options === "undefined") {
    options = {};
  }
  cm2pts = 72 / 2.54;
  if (typeof options.logo_height == "number") {
    height = options.logo_height;
  } else {
    height = LOGOHEIGHT * this.rows;
  }
  if (typeof options.logo_width == "number") {
    width = options.logo_width;
  } else {
    width = this.columns + 2;
  }
  now = new Date();
  ssc = (typeof options.ssc == "boolean" ? options.ssc : false);
  errbars = (typeof options.show_error_bar == "boolean" ? options.show_error_bar : ssc);
  var values = {
    "LOGOHEIGHT": height,
    "LOGOWIDTH": width,
    "BOUNDINGHEIGHT": Math.round(height * cm2pts),
    "BOUNDINGWIDTH": Math.round(width * cm2pts),
    "LOGOLINEHEIGHT": (height / this.rows),
    "CHARSPERLINE": this.columns,
    "BARBITS": this.alphabet.get_ic(),
    "LOGOTYPE": (this.alphabet.has_complement() ? "NA" : "AA"),
    "CREATIONDATE": now.getDate() + "." + (now.getMonth() + 1) + "." + now.getFullYear() + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds(),
    "ERRORBARFRACTION": (typeof options.error_bar_fraction == "number" ? options.error_bar_fraction : 1.0),
    "TICBITS": (typeof options.ticbits == "number" ? options.ticbits : 1.0),
    "TITLE": (typeof options.title == "string" ? options.title : ""),
    "FINEPRINT": (typeof options.fineprint == "string" ? options.fineprint : this.fine_text),
    "XAXISLABEL": (typeof options.xaxislabel == "string" ? options.xaxislabel : ""),
    "YAXISLABEL": (typeof options.yaxislabel == "string" ? options.yaxislabel : "bits"),
    "SSC": ssc,
    "YAXIS": (typeof options.show_y_axis == "boolean" ? options.show_y_axis : this.y_axis),
    "SHOWENDS": (typeof options.show_ends == "boolean" ? options.show_ends : false),
    "ERRBAR": errbars,
    "OUTLINE": (typeof options.show_outline == "boolean" ? options.show_outline : false),
    "NUMBERING": (typeof options.show_numbering == "boolean" ? options.show_numbering : this.x_axis != 0),
    "SHOWINGBOX": (typeof options.show_box == "boolean" ? options.show_box : false),
    "CREATOR": (typeof options.creator == "string" ? options.creator : "motif_logo.js"),
    "FONTSIZE": (typeof options.label_font_size == "number" ? options.label_font_size : 12),
    "TITLEFONTSIZE": (typeof options.title_font_size == "number" ? options.title_font_size : 12),
    "SMALLFONTSIZE": (typeof options.small_font_size == "number" ? options.small_font_size : 6),
    "TOPMARGIN" : (typeof options.top_margin == "number" ? options.top_margin : 0.9),
    "BOTTOMMARGIN": (typeof options.bottom_margin == "number" ? options.bottom_margin : 0.9),
    "COLORDICT": this.alphabet._as_eps_dict(),
    "DATA": this._as_eps_data(ssc, errbars)
  };
  // now this requires that the script containing the template has been imported!
  return motif_logo_template(values);
};

//======================================================================
// end Logo object
//======================================================================

// calculate the exact size (in pixels) of an object drawn on the
// canvas assuming that the background of the canvas is transparent.
function canvas_bounds(ctx, cwidth, cheight) {
  "use strict";
  var data, r, c, top_line, bottom_line, left_line, right_line, 
      txt_width, txt_height;

  // extract the image data
  data = ctx.getImageData(0, 0, cwidth, cheight).data;

  // set initial values
  top_line = -1; bottom_line = -1; left_line = -1; right_line = -1;
  txt_width = 0; txt_height = 0;

  // Find the top-most line with a non-transparent pixel
  for (r = 0; r < cheight; r++) {
    for (c = 0; c < cwidth; c++) {
      if (data[r * cwidth * 4 + c * 4 + 3]) {
        top_line = r;
        break;
      }
    }
    if (top_line != -1) {
      break;
    }
  }
  
  // Only bother looking if we found at least one set pixel... 
  if (top_line != -1) {

    //find the last line with a non-transparent pixel
    for (r = cheight-1; r >= top_line; r--) {
      for(c = 0; c < cwidth; c++) {
        if(data[r * cwidth * 4 + c * 4 + 3]) {
          bottom_line = r;
          break;
        }
      }
      if (bottom_line != -1) {
        break;
      }
    }
    // calculate height
    txt_height = bottom_line - top_line + 1;

    // Find the left-most line with a non-transparent pixel
    for (c = 0; c < cwidth; c++) {
      for (r = top_line; r <= bottom_line; r++) {
        if (data[r * cwidth * 4 + c * 4 + 3]) {
          left_line = c;
          break;
        }
      }
      if (left_line != -1) {
        break;
      }
    }

    //find the right most line with a non-transparent pixel
    for (c = cwidth-1; c >= left_line; c--) {
      for(r = top_line; r <= bottom_line; r++) {
        if(data[r * cwidth * 4 + c * 4 + 3]) {
          right_line = c;
          break;
        }
      }
      if (right_line != -1) {
        break;
      }
    }
    txt_width = right_line - left_line + 1;
  }

  //return the bounds
  return {bound_top: top_line, bound_bottom: bottom_line, 
    bound_left: left_line, bound_right: right_line, width: txt_width, 
    height: txt_height};
}

//======================================================================
// start RasterizedAlphabet
//======================================================================

// Rasterize Alphabet
// 1) Measure width of text at default font for all symbols in alphabet
// 2) sort in width ascending
// 3) Drop the top and bottom 10% (designed to ignore outliers like 'W' and 'I')
// 4) Calculate the average as the maximum scaling factor (designed to stop I becoming a rectangular blob).
// 5) Assume scale of zero would result in width of zero, interpolate scale required to make perfect width font
// 6) Draw text onto temp canvas at calculated scale
// 7) Find bounds of drawn text
// 8) Paint on to another canvas at the desired height (but only scaling width to fit if larger).
var RasterizedAlphabet = function(alphabet, logo_scale, font, width) {
  "use strict";
  var default_size, safety_pad, canvas, ctx, middle, baseline, widths, sizes,
      i, sym, size, tenpercent, avg_width, scale, 
      target_width, target_height;
  //variable prototypes
  this.alphabet = alphabet;
  this.scale = logo_scale;
  this.sym_cache = {};
  this.stack_num_cache = [];
  this.scale_num_cache = [];
  // size of canvas
  default_size = 60; // size of measuring canvas
  safety_pad = 20; // pixels to pad around so we don't miss the edges
  // create a canvas to do our measuring
  canvas = document.createElement("canvas");
  if (!canvas.getContext) throw new Error("No canvas support");
  canvas.width = default_size + 2 * safety_pad;
  canvas.height = default_size + 2 * safety_pad;
  middle = Math.round(canvas.width / 2);
  baseline = Math.round(canvas.height - safety_pad);
  ctx = canvas.getContext('2d');
  if (!supports_text(ctx)) throw new Error("Canvas does not support text");
  ctx.font = font;
  ctx.textAlign = "center";
  ctx.translate(middle, baseline);
  // list of widths
  widths = [];
  sizes = [];
  //now measure each letter in the alphabet
  for (i = 0; i < alphabet.get_size_core(); ++i) {
    // reset the canvas
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    ctx.fillStyle = alphabet.get_colour(i);
    // draw the test text
    ctx.fillText(alphabet.get_symbol(i), 0, 0);
    //measure
    size = canvas_bounds(ctx, canvas.width, canvas.height);
    if (size.width === 0) throw new Error("Invisible symbol!");
    widths.push(size.width);
    sizes[i] = size;
  }
  //sort the widths
  widths.sort(function(a,b) {return a - b;});
  //drop 10% of the items off each end
  tenpercent = Math.floor(widths.length / 10);
  for (i = 0; i < tenpercent; ++i) {
    widths.pop();
    widths.shift();
  }
  //calculate average width
  avg_width = 0;
  for (i = 0; i < widths.length; ++i) {
    avg_width += widths[i];
  }
  avg_width /= widths.length;
  // calculate the target width
  target_width = width * this.scale * 2;
  // calculate scales
  for (i = 0; i < alphabet.get_size_core(); ++i) {
    sym = alphabet.get_symbol(i);
    size = sizes[i];
    // calculate scale
    scale = target_width / Math.max(avg_width, size.width);
    // estimate scaled height
    target_height = size.height * scale;
    // create an appropriately sized canvas
    canvas = document.createElement("canvas");
    canvas.width = target_width;
    canvas.height = target_height + safety_pad * 2;
    // calculate the middle
    middle = Math.round(canvas.width / 2);
    // calculate the baseline
    baseline = Math.round(canvas.height - safety_pad);
    // get the context and prepare to draw the rasterized text
    ctx = canvas.getContext('2d');
    ctx.font = font;
    ctx.fillStyle = alphabet.get_colour(i);
    ctx.textAlign = "center";
    ctx.translate(middle, baseline);
    ctx.save();
    ctx.scale(scale, scale);
    // draw the text
    ctx.fillText(sym, 0, 0);
    ctx.restore();
    this.sym_cache[sym] = {"image": canvas, "size": canvas_bounds(ctx, canvas.width, canvas.height)};
  }
};

RasterizedAlphabet.prototype.get_alphabet = function() {
  return this.alphabet;
};

RasterizedAlphabet.prototype.get_scale = function() {
  return this.scale;
};

RasterizedAlphabet.prototype.draw_stack_sym = function(ctx, letter, dx, dy, dWidth, dHeight) {
  "use strict";
  var entry, image, size;
  entry = this.sym_cache[letter];
  image = entry.image;
  size = entry.size;
  ctx.drawImage(image, 0, size.bound_top -1, image.width, size.height+1, dx, dy, dWidth, dHeight);
};

RasterizedAlphabet.prototype.draw_stack_num = function(ctx, font, stack_width, index) {
  var image, image_ctx, text_length;
  if (index >= this.stack_num_cache.length) {
    image = document.createElement("canvas");
    // measure the text
    image_ctx = image.getContext('2d');
    image_ctx.save();
    image_ctx.font = font;
    text_length = image_ctx.measureText("" + (index + 1)).width;
    image_ctx.restore();
    // resize the canvas to fit
    image.width = Math.ceil(stack_width);
    image.height = Math.ceil(text_length);
    // draw the text
    image_ctx = image.getContext('2d');
    image_ctx.translate(Math.round(stack_width / 2), 0);
    image_ctx.font = font;
    image_ctx.textBaseline = "middle";
    image_ctx.textAlign = "right";
    image_ctx.rotate(-(Math.PI / 2));
    image_ctx.fillText("" + (index + 1), 0, 0);
    this.stack_num_cache[index] = image;
  } else {
    image = this.stack_num_cache[index];
  }
  ctx.drawImage(image, 0, 0);
}

RasterizedAlphabet.prototype.draw_scale_num = function(ctx, font, num) {
  var image, image_ctx, text_size, m_length;
  if (num >= this.scale_num_cache.length) {
    image = document.createElement("canvas");
    // measure the text
    image_ctx = image.getContext('2d');
    image_ctx.font = font;
    text_size = image_ctx.measureText("" + num);
    if (text_size.actualBoundingBoxAscent && text_size.actualBoundingBoxDesent) {
      // resize the canvas to fit
      image.width = Math.ceil(text_size.width);
      image.height = Math.ceil(text_size.actualBoundingBoxAscent + text_size.actualBoundingBoxDesent);
      // draw the text
      image_ctx = image.getContext('2d');
      image_ctx.font = font;
      image_ctx.textAlign = "right";
      image_ctx.fillText("" + num, image.width, text_size.actualBoundingBoxAscent);
    } else {
      // measure width of 'm' to approximate height, we double it later anyway
      m_length = image_ctx.measureText("m").width;
      // resize the canvas to fit
      image.width = Math.ceil(text_size.width);
      image.height = Math.ceil(2 * m_length);
      // draw the text
      image_ctx = image.getContext('2d');
      image_ctx.font = font;
      image_ctx.textAlign = "right";
      image_ctx.textBaseline = "middle";
      image_ctx.fillText("" + num, image.width, m_length);
    }
    this.scale_num_cache[num] = image;
  } else {
    image = this.scale_num_cache[num];
  }
  ctx.drawImage(image, -image.width, -Math.round(image.height / 2))
}

//======================================================================
// end RasterizedAlphabet
//======================================================================

//======================================================================
// start LogoMetrics object
//======================================================================

var LogoMetrics = function(ctx, logo_columns, logo_rows, has_names, has_finetext, x_axis, y_axis) {
  "use strict";
  var i, row_height;
  //variable prototypes
  this.pad_top = (has_names ? 5 : 0);
  this.pad_left = (y_axis ? 10 : 0);
  this.pad_right = (has_finetext ? 15 : 0);
  this.pad_bottom = 0;
  this.pad_middle = 20;
  this.name_height = 14;
  this.name_font = "bold " + this.name_height + "px Times, sans-serif";
  this.name_spacer = 0;
  this.y_axis = y_axis;
  this.y_label = "bits";
  this.y_label_height = 12;
  this.y_label_font = "bold " + this.y_label_height + "px Helvetica, sans-serif";
  this.y_label_spacer = 3;
  this.y_num_height = 12;
  this.y_num_width = 0;
  this.y_num_font = "bold " + this.y_num_height + "px Helvetica, sans-serif";
  this.y_tic_width = 5;
  this.stack_pad_left = 0;
  this.stack_font = "bold 25px Helvetica, sans-serif";
  this.stack_height = 90;
  this.stack_width = 26;
  this.stacks_pad_right = 5;
  this.x_axis = x_axis;
  this.x_num_above = 2;
  this.x_num_height = 12;
  this.x_num_width = 0;
  this.x_num_font = "bold " + this.x_num_height + "px Helvetica, sans-serif";
  this.fine_txt_height = 6;
  this.fine_txt_above = 2;
  this.fine_txt_font = "normal " + this.fine_txt_height + "px Helvetica, sans-serif";
  this.letter_metrics = new Array();
  this.summed_width = 0;
  this.summed_height = 0;
  //calculate the width of the y axis numbers
  ctx.font = this.y_num_font;
  for (i = 0; i <= 2; i++) {
    this.y_num_width = Math.max(this.y_num_width, ctx.measureText("" + i).width);
  }
  //calculate the width of the x axis numbers (but they are rotated so it becomes height)
  if (x_axis == 1) {
    ctx.font = this.x_num_font;
    for (i = 1; i <= logo_columns; i++) {
      this.x_num_width = Math.max(this.x_num_width, ctx.measureText("" + i).width);
    }
  } else if (x_axis == 0) {
    this.x_num_height = 4;
    this.x_num_width = 4;
  } else {
    this.x_num_height = 0;
    this.x_num_width = 0;
  }
  
  //calculate how much vertical space we want to draw this
  //first we add the padding at the top and bottom since that's always there
  this.summed_height += this.pad_top + this.pad_bottom;
  //all except the last row have the same amount of space allocated to them
  if (logo_rows > 1) {
    row_height = this.stack_height + this.pad_middle;
    if (has_names) {
      row_height += this.name_height;
      //the label is allowed to overlap into the spacer
      row_height += Math.max(this.y_num_height/2, this.name_spacer); 
      //the label is allowed to overlap the space used by the other label
      row_height += Math.max(this.y_num_height/2, this.x_num_height + this.x_num_above); 
    } else {
      row_height += this.y_num_height/2; 
      //the label is allowed to overlap the space used by the other label
      row_height += Math.max(this.y_num_height/2, this.x_num_height + this.x_num_above); 
    }
    this.summed_height += row_height * (logo_rows - 1);
  }
  //the last row has the name and fine text below it but no padding
  this.summed_height += this.stack_height + (this.y_axis ? this.y_num_height/2 : 0);

  var fine_txt_total = (has_finetext ? this.fine_txt_height + this.fine_txt_above : 0);
  if (has_names) {
    this.summed_height += fine_txt_total + this.name_height;
    this.summed_height += Math.max((this.y_axis ? this.y_num_height/2 : 0), 
        this.x_num_height + this.x_num_above + this.name_spacer);
  } else {
    this.summed_height += Math.max((this.y_axis ? this.y_num_height/2 : 0), 
        this.x_num_height + this.x_num_above + fine_txt_total);
  }

  //calculate how much horizontal space we want to draw this
  //first add the padding at the left and right since that's always there
  this.summed_width += this.pad_left + this.pad_right;
  if (this.y_axis) {
    //add on the space for the y-axis label
    this.summed_width += this.y_label_height + this.y_label_spacer;
    //add on the space for the y-axis
    this.summed_width += this.y_num_width + this.y_tic_width;
  }
  //add on the space for the stacks
  this.summed_width += (this.stack_pad_left + this.stack_width) * logo_columns;
  //add on the padding after the stacks (an offset from the fine text)
  this.summed_width += this.stacks_pad_right;

};

//======================================================================
// end LogoMetrics object
//======================================================================

//found this trick at http://talideon.com/weblog/2005/02/detecting-broken-images-js.cfm
function image_ok(img) {
  "use strict";
  // During the onload event, IE correctly identifies any images that
  // weren't downloaded as not complete. Others should too. Gecko-based
  // browsers act like NS4 in that they report this incorrectly.
  if (!img.complete) {
    return false;
  }
  // However, they do have two very useful properties: naturalWidth and
  // naturalHeight. These give the true size of the image. If it failed
  // to load, either of these should be zero.
  if (typeof img.naturalWidth !== "undefined" && img.naturalWidth === 0) {
    return false;
  }
  // No other way of checking: assume it's ok.
  return true;
}
  
function supports_text(ctx) {
  "use strict";
  if (!ctx.fillText) {
    return false;
  }
  if (!ctx.measureText) {
    return false;
  }
  return true;
}

//draws the scale, returns the width
function draw_scale(ctx, metrics, alphabet_ic, raster) {
  "use strict";
  var tic_height, i;
  tic_height = metrics.stack_height / alphabet_ic;
  ctx.save();
  ctx.translate(metrics.y_label_height, metrics.y_num_height/2);
  //draw the axis label
  ctx.save();
  ctx.font = metrics.y_label_font;
  ctx.translate(0, metrics.stack_height/2);
  ctx.rotate(-(Math.PI / 2));
  ctx.textAlign = "center";
  ctx.fillText("bits", 0, 0);
  ctx.restore();

  ctx.translate(metrics.y_label_spacer + metrics.y_num_width, 0);

  //draw the axis tics
  ctx.save();
  ctx.translate(0, metrics.stack_height);
  for (i = 0; i <= alphabet_ic; i++) {
    //draw the number
    ctx.save();
    ctx.translate(-1, 0);
    raster.draw_scale_num(ctx, metrics.y_num_font, i);
    ctx.restore();
    //draw the tic
    ctx.fillRect(0, -1, metrics.y_tic_width, 2);
    //prepare for next tic
    ctx.translate(0, -tic_height);
  }
  ctx.restore();

  ctx.fillRect(metrics.y_tic_width - 2, 0, 2, metrics.stack_height)

  ctx.restore();
}

function draw_stack_num(ctx, metrics, row_index, raster) {
  "use strict";
  ctx.save();
  ctx.translate(0, Math.round(metrics.stack_height + metrics.x_num_above));
  if (metrics.x_axis == 1) {
    raster.draw_stack_num(ctx, metrics.x_num_font, metrics.stack_width, row_index);
  } else if (metrics.x_axis == 0) {
    // draw dots instead of the numbers (good for small logos)
    ctx.beginPath();
    var radius = Math.round(metrics.x_num_height / 2);
    ctx.arc(Math.round(metrics.stack_width / 2), radius, radius, 0, 2 * Math.PI, false);
    ctx.fill();
  }
  ctx.restore();
}

function draw_stack(ctx, metrics, symbols, raster) {
  "use strict";
  var preferred_pad, sym_min, i, sym, sym_height, pad;
  preferred_pad = 0;
  sym_min = 5;

  ctx.save();//1
  ctx.translate(0, metrics.stack_height);
  for (i = 0; i < symbols.length; i++) {
    sym = symbols[i];
    sym_height = metrics.stack_height * sym.get_scale();
    
    pad = preferred_pad;
    if (sym_height - pad < sym_min) {
      pad = Math.min(pad, Math.max(0, sym_height - sym_min));
    }
    sym_height -= pad;

    //translate to the correct position
    ctx.translate(0, -(pad/2 + sym_height));

    //draw
    raster.draw_stack_sym(ctx, sym.get_symbol(), 0, 0, metrics.stack_width, sym_height);
    //translate past the padding
    ctx.translate(0, -(pad/2));
  }
  ctx.restore();//1
}

function draw_dashed_line(ctx, pattern, start, x1, y1, x2, y2) {
  "use strict";
  var x, y, len, i, dx, dy, tlen, theta, mulx, muly, lx, ly;
  dx = x2 - x1;
  dy = y2 - y1;
  tlen = Math.pow(dx*dx + dy*dy, 0.5);
  theta = Math.atan2(dy,dx);
  mulx = Math.cos(theta);
  muly = Math.sin(theta);
  lx = [];
  ly = [];
  for (i = 0; i < pattern; ++i) {
    lx.push(pattern[i] * mulx);
    ly.push(pattern[i] * muly);
  }
  i = start;
  x = x1;
  y = y1;
  len = 0;
  ctx.beginPath();
  while (len + pattern[i] < tlen) {
    ctx.moveTo(x, y);
    x += lx[i];
    y += ly[i];
    ctx.lineTo(x, y);
    len += pattern[i];
    i = (i + 1) % pattern.length;
    x += lx[i];
    y += ly[i];
    len += pattern[i];
    i = (i + 1) % pattern.length;
  }
  if (len < tlen) {
    ctx.moveTo(x, y);
    x += mulx * (tlen - len);
    y += muly * (tlen - len);
    ctx.lineTo(x, y);
  }
  ctx.stroke();
}

function draw_trim_background(ctx, metrics, left_start, left_end, left_divider, right_start, right_end, right_divider) {
  "use strict";
  var left_size = left_end - left_start;
  var right_size = right_end - right_start;
  var line_x;

  ctx.save();//s8
  ctx.fillStyle = "rgb(240, 240, 240)";
  if (left_size > 0) {
    ctx.fillRect(left_start * metrics.stack_width, 0, left_size * metrics.stack_width, metrics.stack_height);
  }
  if (right_size > 0) {
    ctx.fillRect(right_start * metrics.stack_width, 0, right_size * metrics.stack_width, metrics.stack_height);
  }
  ctx.fillStyle = "rgb(51, 51, 51)";
  if (left_size > 0 && left_divider) {
    line_x = (left_end * metrics.stack_width) - 0.5;
    draw_dashed_line(ctx, [3], 0, line_x, 0, line_x, metrics.stack_height);
  }
  if (right_size > 0 && right_divider) {
    line_x = (right_start * metrics.stack_width) + 0.5;
    draw_dashed_line(ctx, [3], 0, line_x, 0, line_x, metrics.stack_height);
  }
  ctx.restore();//s8
}

function size_logo_on_canvas(logo, canvas, show_names, scale) {
  "use strict";
  var draw_name, draw_finetext, metrics;
  draw_name = (typeof show_names === "boolean" ? show_names : (logo.get_rows() > 1));
  draw_finetext = (logo.fine_text.length > 0);
  if (canvas.width !== 0 && canvas.height !== 0) {
    return;
  }
  metrics = new LogoMetrics(canvas.getContext('2d'), 
      logo.get_xlate_columns(), logo.get_rows(), draw_name, draw_finetext, logo.x_axis, logo.y_axis);
  if (typeof scale == "number") {
    //resize the canvas to fit the scaled logo
    canvas.width = metrics.summed_width * scale;
    canvas.height = metrics.summed_height * scale;
  } else {
    if (canvas.width === 0 && canvas.height === 0) {
      canvas.width = metrics.summed_width;
      canvas.height = metrics.summed_height;
    } else if (canvas.width === 0) {
      canvas.width = metrics.summed_width * (canvas.height / metrics.summed_height);
    } else if (canvas.height === 0) {
      canvas.height = metrics.summed_height * (canvas.width / metrics.summed_width);
    }
  }
}

function draw_logo_on_canvas(logo, canvas, show_names, scale) {
  "use strict";
  var i, draw_name, draw_finetext, ctx, metrics, raster, pspm_i, pspm, 
      offset, col_index, motif_position, ssc;
  ssc = false;
  draw_name = (typeof show_names === "boolean" ? show_names : (logo.get_rows() > 1));
  draw_finetext = (logo.fine_text.length > 0);
  ctx = canvas.getContext('2d');
  //assume that the user wants the canvas scaled equally so calculate what the best width for this image should be
  metrics = new LogoMetrics(ctx, logo.get_xlate_columns(), logo.get_rows(), draw_name, draw_finetext, logo.x_axis, logo.y_axis);
  if (typeof scale == "number") {
    //resize the canvas to fit the scaled logo
    canvas.width = metrics.summed_width * scale;
    canvas.height = metrics.summed_height * scale;
  } else {
    if (canvas.width === 0 && canvas.height === 0) {
      scale = 1;
      canvas.width = metrics.summed_width;
      canvas.height = metrics.summed_height;
    } else if (canvas.width === 0) {
      scale = canvas.height / metrics.summed_height;
      canvas.width = metrics.summed_width * scale;
    } else if (canvas.height === 0) {
      scale = canvas.width / metrics.summed_width;
      canvas.height = metrics.summed_height * scale;
    } else {
      scale = Math.min(canvas.width / metrics.summed_width, canvas.height / metrics.summed_height);
    }
  }
  // cache the raster based on the assumption that we will be drawing a lot
  // of logos the same size and alphabet
  if (typeof draw_logo_on_canvas.raster_cache === "undefined") {
    draw_logo_on_canvas.raster_cache = [];
  }
  for (i = 0; i < draw_logo_on_canvas.raster_cache.length; i++) {
    raster = draw_logo_on_canvas.raster_cache[i];
    if (raster.get_alphabet().equals(logo.alphabet) &&
        Math.abs(raster.get_scale() - scale) < 0.1) break;
    raster = null;
  }
  if (raster == null) {
    raster = new RasterizedAlphabet(logo.alphabet, scale, metrics.stack_font, metrics.stack_width);
    draw_logo_on_canvas.raster_cache.push(raster);
  }
  ctx = canvas.getContext('2d');
  ctx.save();//s1
  ctx.scale(scale, scale);
  ctx.save();//s2
  ctx.save();//s7
  //create margin
  ctx.translate(Math.round(metrics.pad_left), Math.round(metrics.pad_top));
  for (pspm_i = 0; pspm_i < logo.get_rows(); ++pspm_i) {
    pspm = logo.get_pspm(pspm_i);
    offset = logo.get_offset(pspm_i);
    //optionally draw name if this isn't the last row or is the only row 
    if (draw_name && (logo.get_rows() == 1 || pspm_i != (logo.get_rows()-1))) {
      ctx.save();//s4
      ctx.translate(Math.round(metrics.summed_width/2), Math.round(metrics.name_height));
      ctx.font = metrics.name_font;
      ctx.textAlign = "center";
      ctx.fillText(pspm.name, 0, 0);
      ctx.restore();//s4
      ctx.translate(0, Math.round(metrics.name_height + 
          Math.min(0, metrics.name_spacer - metrics.y_num_height/2)));
    }
    //draw scale
    if (logo.y_axis) draw_scale(ctx, metrics, logo.alphabet.get_ic(), raster);
    ctx.save();//s5
    //translate across past the scale
    if (logo.y_axis) {
      ctx.translate(Math.round(metrics.y_label_height + metrics.y_label_spacer + 
        metrics.y_num_width + metrics.y_tic_width), Math.round(metrics.y_num_height / 2));
    }
    //draw the trimming background
    if (pspm.get_left_trim() > 0 || pspm.get_right_trim() > 0) {
      var left_start = offset * logo.get_xlate_nsyms();
      var left_end = (offset + pspm.get_left_trim()) * logo.get_xlate_nsyms();
      var left_divider = true;
      if (left_end < logo.get_xlate_start() || left_start > logo.get_xlate_end()) {
        // no overlap
        left_start = 0;
        left_end = 0;
        left_divider = false;
      } else {
        if (left_start < logo.get_xlate_start()) {
          left_start = logo.get_xlate_start();
        }
        if (left_end > logo.get_xlate_end()) {
          left_end = logo.get_xlate_end();
          left_divider = false;
        }
        left_start -= logo.get_xlate_start();
        left_end -= logo.get_xlate_start();
        if (left_end < left_start) {
          left_start = 0;
          left_end = 0;
          left_divider = false;
        }
      }
      var right_end = (offset + pspm.get_motif_length()) * logo.get_xlate_nsyms();
      //var right_start = right_end - (pspm.get_left_trim() * logo.get_xlate_nsyms());
      var right_start = right_end - (pspm.get_right_trim() * logo.get_xlate_nsyms());
      var right_divider = true;
      if (right_end < logo.get_xlate_start() || right_start > logo.get_xlate_end()) {
        // no overlap
        right_start = 0;
        right_end = 0;
        right_divider = false;
      } else {
        if (right_start < logo.get_xlate_start()) {
          right_start = logo.get_xlate_start();
          right_divider = false;
        }
        if (right_end > logo.get_xlate_end()) {
          right_end = logo.get_xlate_end();
        }
        right_start -= logo.get_xlate_start();
        right_end -= logo.get_xlate_start();
        if (right_end < right_start) {
          right_start = 0;
          right_end = 0;
          right_divider = false;
        }
      }
      draw_trim_background(ctx, metrics, left_start, left_end, left_divider, right_start, right_end, right_divider);
    }
    //draw letters
    var xlate_col;
    for (xlate_col = logo.get_xlate_start(); xlate_col < logo.get_xlate_end(); xlate_col++) {
      ctx.translate(metrics.stack_pad_left,0);
      col_index = Math.floor(xlate_col / logo.get_xlate_nsyms());
      if (xlate_col % logo.get_xlate_nsyms() == 0) {
        if (col_index >= offset && col_index < (offset + pspm.get_motif_length())) {
          motif_position = col_index - offset;
          draw_stack_num(ctx, metrics, motif_position, raster);
          draw_stack(ctx, metrics, pspm.get_stack(motif_position, logo.alphabet, ssc), raster);
        }
      } else {
        if (col_index >= offset && col_index < (offset + pspm.get_motif_length())) {
          ctx.save();// s5.1
          ctx.translate(0, Math.round(metrics.stack_height));
          // TODO draw a dot or dash or something to indicate continuity of the motif
          ctx.restore(); //s5.1
        }
      }
      ctx.translate(Math.round(metrics.stack_width), 0);
    }
    ctx.restore();//s5
    ////optionally draw name if this is the last row but isn't the only row 
    if (draw_name && (logo.get_rows() != 1 && pspm_i == (logo.get_rows()-1))) {
      //translate vertically past the stack and axis's        
      ctx.translate(0, metrics.y_num_height/2 + metrics.stack_height + 
          Math.max(metrics.y_num_height/2, metrics.x_num_above + metrics.x_num_width + metrics.name_spacer));

      ctx.save();//s6
      ctx.translate(metrics.summed_width/2, metrics.name_height);
      ctx.font = metrics.name_font;
      ctx.textAlign = "center";
      ctx.fillText(pspm.name, 0, 0);
      ctx.restore();//s6
      ctx.translate(0, metrics.name_height);
    } else {
      //translate vertically past the stack and axis's        
      ctx.translate(0, metrics.y_num_height/2 + metrics.stack_height + 
          Math.max(metrics.y_num_height/2, metrics.x_num_above + metrics.x_num_width));
    }
    //if not the last row then add middle padding
    if (pspm_i != (logo.get_rows() -1)) {
      ctx.translate(0, metrics.pad_middle);
    }
  }
  ctx.restore();//s7
  if (logo.fine_text.length > 0) {
    ctx.translate(metrics.summed_width - metrics.pad_right, metrics.summed_height - metrics.pad_bottom);
    ctx.font = metrics.fine_txt_font;
    ctx.textAlign = "right";
    ctx.fillText(logo.fine_text, 0,0);
  }
  ctx.restore();//s2
  ctx.restore();//s1
}

function create_canvas(c_width, c_height, c_id, c_title, c_display) {
  "use strict";
  var canvas = document.createElement("canvas");
  //check for canvas support before attempting anything
  if (!canvas.getContext) {
    return null;
  }
  var ctx = canvas.getContext('2d');
  //check for html5 text drawing support
  if (!supports_text(ctx)) {
    return null;
  }
  //size the canvas
  canvas.width = c_width;
  canvas.height = c_height;
  canvas.id = c_id;
  canvas.title = c_title;
  canvas.style.display = c_display;
  return canvas;
}

function logo_1(alphabet, fine_text, pspm) {
  "use strict";
  var logo = new Logo(alphabet, fine_text);
  logo.add_pspm(pspm);
  return logo;
}

function logo_2(alphabet, fine_text, target, query, query_offset) {
  "use strict";
  var logo = new Logo(alphabet, fine_text);
  if (query_offset < 0) {
    logo.add_pspm(target, -query_offset);
    logo.add_pspm(query);
  } else {
    logo.add_pspm(target);
    logo.add_pspm(query, query_offset);
  }      
  return logo;
}

/*
 * Specifies an alternate source for an image.
 * If the image with the image_id specified has
 * not loaded then a generated logo will be used 
 * to replace it.
 *
 * Note that the image must either have dimensions
 * or a scale must be set.
 */
function alternate_logo(logo, image_id, scale) {
  "use strict";
  var image = document.getElementById(image_id);
  if (!image) {
    alert("Can't find specified image id (" +  image_id + ")");
    return;
  }
  //if the image has loaded then there is no reason to use the canvas
  if (image_ok(image)) {
    return;
  }
  //the image has failed to load so replace it with a canvas if we can.
  var canvas = create_canvas(image.width, image.height, image_id, image.title, image.style.display);
  if (canvas === null) {
    return;
  }
  //draw the logo on the canvas
  draw_logo_on_canvas(logo, canvas, null, scale);
  //replace the image with the canvas
  image.parentNode.replaceChild(canvas, image);
}

/*
 * Specifies that the element with the specified id
 * should be replaced with a generated logo.
 */
function replace_logo(logo, replace_id, scale, title_txt, display_style) {
  "use strict";
  var element = document.getElementById(replace_id);
  if (!replace_id) {
    alert("Can't find specified id (" + replace_id + ")");
    return;
  }
  //found the element!
  var canvas = create_canvas(50, 120, replace_id, title_txt, display_style);
  if (canvas === null) {
    return;
  }
  //draw the logo on the canvas
  draw_logo_on_canvas(logo, canvas, null, scale);
  //replace the element with the canvas
  element.parentNode.replaceChild(canvas, element);
}

/*
 * Fast string trimming implementation found at
 * http://blog.stevenlevithan.com/archives/faster-trim-javascript
 *
 * Note that regex is good at removing leading space but
 * bad at removing trailing space as it has to first go through
 * the whole string.
 */
function trim (str) {
  "use strict";
  var ws, i;
  str = str.replace(/^\s\s*/, '');
  ws = /\s/; i = str.length;
  while (ws.test(str.charAt(--i)));
  return str.slice(0, i + 1);
}
</script>
    <script>
var LEGEND_LINE = 16;
var LEGEND_FONT = "Helvetica";
var LEGEND_PAD = 5;

var Dasher = function(ctx, start_x, start_y, pattern) {
  if (typeof pattern === "undefined") pattern = [];
  this.ctx = ctx;
  this.x = start_x;
  this.y = start_y;
  this.pattern = pattern;
  this.index = 0;     // where in the pattern are we up to?
  this.fragment = 0;  // how much of the current pattern have we drawn
  this.on = true;     // pen on paper?
  ctx.moveTo(start_x, start_y);
};

Dasher.prototype.dashTo = function(x, y) {
  var dx = x - this.x;
  var dy = y - this.y;
  var d = Math.pow(dx * dx + dy * dy, 0.5);
  if (this.pattern.length == 0) {
    // when no pattern is specified this just draws lines
    this.ctx.lineTo(x, y);
  } else {
    // calculate distance to complete dash
    var dc = this.pattern[this.index] - this.fragment;
    while (dc <= d) {
      // calculate the fraction of the line needed
      var f = dc / d;
      this.x += dx * f;
      this.y += dy * f;
      if (this.on) {
        this.ctx.lineTo(this.x, this.y);
      } else {
        this.ctx.moveTo(this.x, this.y);
      }
      // move to the next dash
      this.fragment = 0;
      // skip empty dashes, just toggling on state
      do {
        this.index = (this.index + 1) % this.pattern.length;
        this.on = !this.on;
      } while (this.pattern[this.index] <= 0);
      // update variables
      dc = this.pattern[this.index];
      dx = x - this.x;
      dy = y - this.y;
      d = Math.pow(dx * dx + dy * dy, 0.5);
    }
    this.fragment += d;
    this.x = x;
    this.y = y;
    if (this.on) {
      this.ctx.lineTo(this.x, this.y);
    } else {
      this.ctx.moveTo(this.x, this.y);
    }
  }
}

var CentrimoResult = function(name, sig, colour, motif_length, 
    total_sites, site_counts, neg_total_sites, neg_site_counts) {
  "use strict";
  if (typeof name === "undefined") {
    name = "";
  }
  if (typeof sig === "undefined") {
    sig = "";
  }
  if (typeof colour == "undefined") {
    colour = "#000000";
  }
  this.name = name;
  this.sig = sig;
  this.colour = colour;
  this.motif_length = motif_length;
  this.total_sites = total_sites;
  this.site_counts = site_counts;
  this.has_neg = (typeof neg_total_sites === "number" && 
      typeof neg_site_counts === "object" && neg_site_counts instanceof Array);
  this.neg_total_sites = neg_total_sites;
  this.neg_site_counts = neg_site_counts;
};

CentrimoResult.prototype.get_site_count = function (index, mirror, neg) {
  count = neg ? this.neg_site_counts[index] : this.site_counts[index];
  if (mirror) {
    i_mirror = this.site_counts.length - 1 - index;
    return (count + (neg ? this.neg_site_counts[i_mirror] : this.site_counts[i_mirror]));
  } else {
    return count;
  }
};

/*
 * CentrimoRSet
 * Construct a centrimo result set.
 */
var CentrimoRSet = function(sequence_length) {
  "use strict";
  this.sequence_length = sequence_length;
  this.results = [];
};

/*
 * seq_len
 * Get the sequence length of the result set.
 */
CentrimoRSet.prototype.seq_len = function() {
  "use strict";
  return this.sequence_length;
};

/*
 * add
 * Add a centrimo result to the set
 */
CentrimoRSet.prototype.add = function(name, sig, colour, motif_length, 
    total_sites, site_counts, neg_total_sites, neg_site_counts) {
  "use strict";
  this.results.push(new CentrimoResult(name, sig, colour, motif_length, 
    total_sites, site_counts, neg_total_sites, neg_site_counts));
};

/*
 * count
 * Return the count of centrimo results.
 */
CentrimoRSet.prototype.count = function() {
  "use strict";
  return this.results.length;
};

/*
 *  get
 *  Get an entry in the result set.
 */
CentrimoRSet.prototype.get = function(index) {
  "use strict";
  return this.results[index];
};

/*
 * CentrimoLine
 */
var CentrimoLine = function(name, sig, colour, dash, thickness, show_on_legend, xlist, ylist) {
  "use strict";
  if (xlist.length != ylist.length) {
    throw new Error("The list of x and y points must be the same length.");
  }
  this.xlist = xlist;
  this.ylist = ylist;
  this.name = name;
  this.sig = sig;
  this.colour = colour;
  this.dash = dash;
  this.thickness = thickness;
  this.show_on_legend = show_on_legend;
  this.max_prob = -1;
};

/*
 * trim
 *
 * Removes points from the ends so the lines are the same length.
 */
CentrimoLine.prototype.trim = function(left, right) {
  "use strict";
  var lefti, righti, gradient, gap, left_y, right_y;
  if (this.xlist.length == 0) return;
  if (typeof left !== "number"|| isNaN(left)) {
    throw new Error("left trim is not a number");
  }
  if (typeof right !== "number" || isNaN(right)) {
    throw new Error("right trim is not a number");
  }
  for (lefti = 0; lefti < this.xlist.length; lefti++) {
    if (this.xlist[lefti] >= left) {
      break;
    }
  }
  if (lefti === 0 && this.xlist[0] !== left) {
    throw new Error("Attempt to undertrim line on the left.");
  }
  for (righti = this.xlist.length - 1; righti >= 0; righti--) {
    if (this.xlist[righti] <= right) {
      break;
    }
  }
  if (righti === (this.xlist.length - 1) && this.xlist[righti] !== right) {
    throw new Error("Attempt to undertrim line on the right.");
  }
  if (lefti == this.xlist.length || righti == -1) {
    // all points outside of drawable region
    this.xlist = [];
    this.ylist = [];
    return;
  }
  if (this.xlist[lefti] != left) {
    // create a new point that is exactly at left by interpolating
    gradient = (this.ylist[lefti] - this.ylist[lefti-1]) / 
      (this.xlist[lefti] - this.xlist[lefti-1]);
    gap = left - this.xlist[lefti-1];
    left_y = this.ylist[lefti-1] + gradient * gap;
    this.xlist.splice(0, lefti, left);
    this.ylist.splice(0, lefti, left_y);
    righti = righti - lefti + 1;
  } else {
    this.xlist.splice(0, lefti);
    this.ylist.splice(0, lefti);
    righti -= lefti;
  }
  if (this.xlist[righti] != right) {
    // create a new point that is exactly at right by interpolating
    gradient = (this.ylist[righti + 1] - this.ylist[righti]) /
      (this.xlist[righti + 1] - this.xlist[righti]);
    gap = right - this.xlist[righti];
    right_y = this.ylist[righti] + gradient * gap;
    // truncate the lists
    this.xlist.length = righti + 1;
    this.ylist.length = righti + 1;
    // push the new item on the end of the lists
    this.xlist.push(right);
    this.ylist.push(right_y);
  } else {
    // truncate the lists
    this.xlist.length = righti + 1;
    this.ylist.length = righti + 1;
  }
  this.max_prob = -1;
};

CentrimoLine.prototype.max = function() {
  "use strict";
  var y_max, i;
  if (this.max_prob != -1) {
    return this.max_prob;
  }
  y_max = 0;
  for (i = 0; i < this.xlist.length; i++) {
    if (this.ylist[i] > y_max) {
      y_max = this.ylist[i];
    }
  }
  this.max_prop = y_max;
  return this.max_prop;
};

/*
 * CentrimoScale
 *
 * Calculates the increments on the y axis
 */
var CentrimoScale = function(max_prob) {
  "use strict";
  var decimals, inc, rounder, max, inc_plus;
  if (max_prob === 0) {
    this.max = 0.01;
    this.inc = 0.002;
    this.digits = 3;
    return;
  }
  // find the minimum number of decimals needed to display the largest
  // digit of the maximum probability
  decimals = Math.ceil(-(Math.log(max_prob) / Math.log(10)));
  // calculate an increment which is (at minimum) 10 times smaller the the max
  inc = Math.pow(10, -(decimals+1));
  // round-up the maximum probabilty to its largest digit
  rounder = Math.pow(10, decimals);
  max = Math.ceil(max_prob * rounder) / rounder;
  // adjust the increment so it's between 5 and 12 times the maximum
  // probability
  if (inc * 5 < max && inc * 12 > max) {
    inc *= 1;
  } else if (inc * 10 < max && inc * 24 > max) {
    inc *= 2;
  } else if (inc * 25 < max && inc * 60 > max) {
    inc *= 5;
  } else if (inc * 50 < max && inc * 120 > max) {
    inc *= 10;
  }
  max += inc;
  inc_plus = (1.125 * inc);
  while (max - inc_plus > max_prob) {
    max -= inc;
  }
  max = Math.min(max, 1.0);
  this.max = max;
  this.inc = inc;
  this.digits = decimals+1;
};

var CentrimoLegendMetrics = function(lw, lh, id_w, pv_w, sq_w) {
  "use strict";
  this.width = lw;
  this.height = lh;
  this.id_width = id_w;
  this.pv_width = pv_w;
  this.sq_width = sq_w;
};

var CentrimoGraphMetrics = function(legend_metrics, top_edge, bottom_edge,
    left_mark, left_val, right_mark, right_val) {
  if (typeof legend_metrics !== "object" || legend_metrics === null) {
    this.legend_width = 10;
    this.legend_height = 10;
  } else {
    this.legend_width = legend_metrics.width;
    this.legend_height = legend_metrics.height;
  }
  this.top_edge = top_edge;
  this.bottom_edge = bottom_edge;
  this.left_mark = left_mark;
  this.left_val = left_val;
  this.right_mark = right_mark;
  this.right_val = right_val;
};

/*
 * CentrimoGraph
 * Takes a results set and a window weight array and produces a graph. 
 * The weights in the window_weights should be non-negative and sum to 1.
 */
var CentrimoGraph = function(rset, window_weights, fine_text, start, end, mirror) {
  "use strict";
  var trim_left, trim_right, i, j, k, result, x, y, xpos, ypos, positions;
  var y_neg, ypos_neg, line_thickness;

  line_thickness = (window_weights.length < 10 ? 1 : 3);
  if (typeof fine_text !== "string") {
    fine_text = "";
  }
  if (typeof mirror !== "boolean") mirror = false;
  this.mirror = mirror;
  if (mirror) {
    if (typeof start === "number") {
      start = Math.max(0, start);
    } else {
      start = 0;
    }
  }
  this.fine_text = fine_text;
  this.lines = [];
  for (i = 0; i < rset.count(); i++) {
    result = rset.get(i);
    x = [];
    y = [];
    if (result.has_neg) {
      y_neg = [];
    }
    xpos = (result.motif_length - rset.seq_len() + (window_weights.length - 1)) / 2;
    if (typeof trim_left === "undefined") {
      trim_left = xpos;
    } else if (trim_left < xpos) {
      trim_left = xpos;
    }
    positions = result.site_counts.length - window_weights.length + 1;
    for (j = 0; j < positions; j++, xpos += 1) {
      ypos = 0;
      // avoid division by zero when no sites are found
      if (result.total_sites > 0) {
        for (k = 0; k < window_weights.length; k++) {
          ypos += window_weights[k] * result.get_site_count(j + k, mirror, 0);
        }
        ypos /= result.total_sites;
      }
      x.push(xpos);
      y.push(ypos);
      // handle the negative dataset
      if (result.has_neg) {
        ypos_neg = 0;
        if (result.neg_total_sites > 0) {
          for (k = 0; k < window_weights.length; k++) {
            ypos_neg += window_weights[k] * result.get_site_count(j + k, mirror, 1);
          }
          ypos_neg /= result.neg_total_sites;
        }
        y_neg.push(ypos_neg);
      }
    }
    // subtract 1 from xpos because for loop will increment it one more than needed.
    xpos -= 1;
    this.lines.push(new CentrimoLine(result.name, result.sig, result.colour, [], line_thickness, true, x, y));
    if (result.has_neg) {
      this.lines.push(new CentrimoLine(result.name, result.sig, result.colour, [6,4], 2, false, x.slice(0), y_neg));
    }
    if (positions > 0) {
      if (typeof trim_right === "undefined") {
        trim_right = xpos;
      } else if (trim_right > xpos) {
        trim_right = xpos;
      }
    }
  }
  if (typeof start !== "undefined" && start != null) {
    if (start > trim_left) {
      trim_left = start;
    }
    this.start = start;
  } else {
    this.start = -Math.ceil(rset.seq_len() / 2);
  }
  if (typeof end !== "undefined" && end != null) {
    if (end < trim_right) {
      trim_right = end;
    }
    this.end = end;
  } else {
    this.end = Math.floor(rset.seq_len() / 2);
  }
  this.max_prob = 0;
  for (i = 0; i < this.lines.length; i++) {
    this.lines[i].trim(trim_left, trim_right);
    this.max_prob = Math.max(this.max_prob, this.lines[i].max());
  }
  this.scale = new CentrimoScale(this.max_prob);
};

/*
 * draw_graph
 *
 * Draws a motif probability graph
 */
CentrimoGraph.prototype.draw_graph = function (ctx, w, h, draw_legend, legend_x, legend_y) {
  "use strict";
  var gap, l_margin, t_margin, b_margin, r_margin, legend_metrics, 
      legend_width, legend_height;
  gap = 10;
  l_margin = gap + 30 + 10 * (2 + this.scale.digits);
  t_margin = 20;
  b_margin = 60;
  r_margin = 30;
  legend_metrics = this.measure_legend(ctx);
  // setting global
  legend_width = legend_metrics.width;
  legend_height = legend_metrics.height;
  // constrain legend to within graph area
  legend_x = Math.round(legend_x);
  legend_y = Math.round(legend_y);
  if (legend_x < (l_margin + gap)) {
    legend_x = l_margin + gap;
  } else if ((legend_x + legend_metrics.width) > (w - r_margin - gap)) {
    legend_x = w - r_margin - legend_metrics.width - gap;
  }
  if (legend_y < (t_margin + gap)) {
    legend_y = t_margin + gap;
  } else if ((legend_y + legend_metrics.height) > (h - b_margin - gap)) {
    legend_y = h - b_margin - legend_metrics.height - gap;
  }

  // draw graph
  ctx.save();
  // draw border
  ctx.beginPath();
  ctx.moveTo(l_margin - 0.5, t_margin +0.5);
  ctx.lineTo(l_margin - 0.5, h - (b_margin - 0.5));
  ctx.lineTo(w - r_margin - 0.5, h - (b_margin - 0.5));
  ctx.lineTo(w - r_margin - 0.5, t_margin +0.5);
  ctx.closePath();
  ctx.stroke();
  // draw fineprint
  ctx.save();
  ctx.font = "9px Helvetica";
  ctx.textAlign = "right";
  ctx.textBaseline = "bottom";
  ctx.fillText(this.fine_text, w - 1, h - 2);
  ctx.restore();
  // draw y axis
  ctx.save();
  ctx.translate(l_margin, t_margin);
  this.draw_y_axis(ctx, 0, h - (t_margin + b_margin));
  ctx.restore();
  // draw y labels
  ctx.save();
  ctx.translate(gap, t_margin);
  this.draw_y_axis_label(ctx, l_margin, h - (t_margin + b_margin));
  ctx.restore();
  // draw x axis
  ctx.save();
  ctx.translate(l_margin, h - b_margin);
  this.draw_x_axis(ctx, w - (l_margin + r_margin), b_margin);
  ctx.restore();
  // draw top axis
  ctx.save();
  ctx.translate(l_margin, t_margin);
  this.draw_top_axis(ctx, w - (l_margin + r_margin), 0);
  ctx.restore();
  // draw x axis labels
  ctx.save();
  ctx.translate(l_margin, h - b_margin);
  this.draw_x_axis_label(ctx, w - (l_margin + r_margin), b_margin - gap);
  ctx.restore();
  // draw lines
  ctx.save();
  ctx.translate(l_margin, t_margin);
  this.draw_lines(ctx, w - (l_margin + r_margin), h - (t_margin + b_margin), 8);
  ctx.restore();
  // draw legend
  if (draw_legend) { 
    ctx.save();
    ctx.translate(legend_x, legend_y);
    this.draw_legend(ctx, legend_metrics);
    ctx.restore();
  }
  ctx.restore();
  return new CentrimoGraphMetrics(legend_metrics, t_margin, h - b_margin,
      l_margin, this.start, w - r_margin, this.end);
};

/*
 * draw_x_axis
 *
 */
CentrimoGraph.prototype.draw_x_axis = function(ctx, w, h) {
  "use strict";
  var scale_x, length, tic_inc, tic_min, tic_max, i, x;
  // pixels per unit
  scale_x = w / (this.end - this.start);
  // calculate a good tic increment
  length = this.end - this.start;
  if (length > 50) {
    // multiple of 10
    tic_inc = Math.max(1, Math.round(length / 100)) * 10;
  } else if (length > 25) {
    tic_inc = 5;
  } else if (length > 10) {
    tic_inc = 2;
  } else {
    tic_inc = 1;
  }
  // work out the min and max values within the start and end
  tic_min = Math.round(this.start / tic_inc) * tic_inc;
  if (tic_min < this.start) {
    tic_min += tic_inc;
  }
  tic_max = Math.round(this.end / tic_inc) * tic_inc;
  if (tic_max > this.end) {
    tic_max -= tic_inc;
  }
  // draw the tics
  ctx.save();
  ctx.font = "14pt Helvetica";
  ctx.textBaseline = "top";
  ctx.textAlign = "center";
  for (i = tic_min; i <= tic_max; i+= tic_inc) {
    x = Math.round((i - this.start) * scale_x) + 0.5;
    ctx.fillText(""+i, x, 5);
    if (i == this.start || i == this.end) continue;
    ctx.beginPath();
    ctx.moveTo(x, -5);
    ctx.lineTo(x, 3);
    ctx.stroke();
  }
  
  ctx.restore();
};

/*
 * draw_top_axis
 *
 */
CentrimoGraph.prototype.draw_top_axis = function(ctx, w, h) {
  "use strict";
  var scale_x, length, tic_inc, tic_min, tic_max, i, x;
  // pixels per unit
  scale_x = w / (this.end - this.start);
  // calculate a good tic increment
  length = this.end - this.start;
  if (length > 50) {
    // multiple of 10
    tic_inc = Math.max(1, Math.round(length / 100)) * 10;
  } else if (length > 25) {
    tic_inc = 5;
  } else {
    tic_inc = 1;
  }
  // work out the min and max values within the start and end
  tic_min = Math.round(this.start / tic_inc) * tic_inc;
  if (tic_min < this.start) {
    tic_min += tic_inc;
  }
  tic_max = Math.round(this.end / tic_inc) * tic_inc;
  if (tic_max > this.end) {
    tic_max -= tic_inc;
  }
  // draw the tics
  ctx.save();
  ctx.font = "14pt Helvetica";
  ctx.textBaseline = "top";
  ctx.textAlign = "center";
  for (i = tic_min; i <= tic_max; i+= tic_inc) {
    if (i == this.start || i == this.end) continue;
    x = Math.round((i - this.start) * scale_x) + 0.5;
    ctx.beginPath();
    ctx.moveTo(x, 0);
    ctx.lineTo(x, 8);
    ctx.stroke();
  }
  ctx.restore();
};

/*
 * draw_x_axis_label
 */
CentrimoGraph.prototype.draw_x_axis_label = function(ctx, w, h) {
  "use strict";
  ctx.save();
  ctx.font = "14pt Helvetica";
  ctx.textAlign = "center";
  ctx.textBaseline = "bottom";
  ctx.fillText((this.mirror ? 
        "Distance of Best Site from Sequence Center" : 
        "Position of Best Site in Sequence"), w/2, h);
  ctx.restore();
};

/*
 * draw_y_axis
 *
 * TODO some work needs to be done to allow moving the zero
 */
CentrimoGraph.prototype.draw_y_axis = function(ctx, w, h) {
  "use strict";
  var y_scale, p, y;
  ctx.save();
  ctx.font = "14pt Helvetica";
  ctx.textBaseline = "middle";
  ctx.textAlign = "right";

  y_scale = h / this.scale.max;
  for (p = 0; p < this.scale.max; p += this.scale.inc) {
    y = Math.round(h - p * y_scale) + 0.5;
    this.draw_y_tic(ctx, this.scale.digits, y, p);
  }
  this.draw_y_tic(ctx, this.scale.digits, 0.5, this.scale.max);

  ctx.restore();
};

/*
 * draw_y_tic
 */
CentrimoGraph.prototype.draw_y_tic = function(ctx, digits, y, p) {
  "use strict";
  ctx.beginPath();
  ctx.moveTo(5, y);
  ctx.lineTo(-3, y);
  ctx.stroke();
  ctx.fillText(p.toFixed(digits), -5, y);
};

/*
 * draw_y_axis_label
 */
CentrimoGraph.prototype.draw_y_axis_label = function(ctx, w, h) {
  "use strict";
  ctx.save();
  ctx.translate(0, h/2);
  ctx.rotate(-Math.PI / 2);
  ctx.font = "14pt Helvetica";
  ctx.textBaseline = "top";
  ctx.textAlign = "center";
  ctx.fillText("Probability", 0, 0);
  ctx.restore();
};

/*
 * draw_lines
 */
CentrimoGraph.prototype.draw_lines = function(ctx, w, h, tic_size) {
  "use strict";
  var scale_y, scale_x, i, line, x_points, y_points, j, x, y, dasher;
  if (typeof tic_size === "undefined") {
    tic_size = 0;
  }
  scale_y = h / this.scale.max;
  scale_x = w / (this.end - this.start);
  // draw the central line
  if (0 > this.start && 0 < this.end) {
    ctx.save();
    ctx.translate((-this.start) * scale_x, 0);
    ctx.strokeStyle = '#DDD';
    ctx.beginPath();
    ctx.moveTo(0.5, tic_size);
    ctx.lineTo(0.5, h - tic_size);
    ctx.stroke();
    ctx.restore();
  }
  // draw the lines
  ctx.save();
  ctx.lineJoin = "bevel";
  ctx.miterLimit = 0;
  for (i = 0; i < this.lines.length; i++) {
    line = this.lines[i];
    ctx.lineWidth = line.thickness;
    x_points = line.xlist;
    y_points = line.ylist;
    if (x_points.length > 1) {
      ctx.strokeStyle = line.colour;
      ctx.beginPath();
      for (j = 0; j < x_points.length; j++) {
        if (isNaN(x_points[j])) {
          throw new Error("X NaN!");
        }
        if (isNaN(y_points[j])) {
          throw new Error("Y NaN!");
        }
        x = (x_points[j] - this.start) * scale_x;
        y = h - y_points[j] * scale_y;
        if (j === 0) {
          dasher = new Dasher(ctx, x, y, line.dash);
        } else {
          dasher.dashTo(x, y);
        }
      }
      ctx.stroke();
    } else if (x_points.length == 1) {
      if (isNaN(x_points[0])) {
        throw new Error("X NaN!");
      }
      if (isNaN(y_points[0])) {
        throw new Error("Y NaN!");
      }
      x = (x_points[0] - this.start) * scale_x;
      y = h - y_points[0] * scale_y;
      ctx.fillStyle = line.colour;
      ctx.beginPath();
      ctx.arc(x, y, 2, 0, 2*Math.PI, false);
      ctx.fill();
    }
  }
  ctx.restore();
};

/*
 * measure_legend
 */
CentrimoGraph.prototype.measure_legend = function(ctx) {
  "use strict";
  var lw, lh, sq_w, id_w, pv_w, lines, i, line, len;
  // initilise the line height to the size of the padding
  lh = 2 * LEGEND_PAD;
  // calculate the column widths
  sq_w = LEGEND_LINE - 2;
  id_w = 0;
  pv_w = 0;
  ctx.save();
  ctx.font = "" + LEGEND_LINE + "px " + LEGEND_FONT; 
  for (i = 0; i < this.lines.length; i++) {
    line = this.lines[i];
    if (!line.show_on_legend) {
      continue;
    }
    lh += LEGEND_LINE * 1.2;
    len = ctx.measureText(line.name).width;
    if (id_w < len) {
      id_w = len;
    }
    len = ctx.measureText(line.sig).width;
    if (pv_w < len) {
      pv_w = len;
    }
  }
  lh = Math.round(lh);
  ctx.restore();
  // legend width is a function of the column widths
  lw = id_w + pv_w + sq_w + 4 * LEGEND_PAD;

  return new CentrimoLegendMetrics(lw, lh, id_w, pv_w, sq_w);
};

/*
 * draw_legend
 */
CentrimoGraph.prototype.draw_legend = function(ctx, metrics) {
  "use strict";
  var ln_h, pad, w, h, id_w, pv_w, sq_w, id_x, pv_x, sq_x, i, line;
  if (this.lines.length === 0) {
    return;
  }
  ln_h = LEGEND_LINE;
  pad = LEGEND_PAD;
  w = metrics.width;
  h = metrics.height;
  id_w = metrics.id_width;
  pv_w = metrics.pv_width;
  sq_w = metrics.sq_width;
  id_x = 0;
  pv_x = id_x + id_w + pad;
  sq_x = pv_x + pv_w + pad;

  ctx.save();
  ctx.font = "" + ln_h + "px " + LEGEND_FONT;
  ctx.textAlign = "left";
  ctx.textBaseline = "alphabetic";
  // draw it
  ctx.save();
  ctx.fillStyle = 'white';
  ctx.fillRect(0.5, 0.5, w-1, h-1);
  ctx.strokeStyle = 'black';
  ctx.strokeRect(0.5, 0.5, w-1, h-1);
  ctx.restore();
  ctx.translate(pad, pad);
  ctx.fillStyle = "black";
  for (i = 0; i < this.lines.length; i++) {
    line = this.lines[i];
    if (!line.show_on_legend) {
      continue;
    }
    ctx.translate(0, ln_h);
    ctx.save();
    ctx.fillStyle = line.colour;
    ctx.fillRect(sq_x, -sq_w + 0.1 * ln_h, sq_w, sq_w);
    ctx.restore();
    ctx.fillText(line.name, id_x, 0);
    ctx.fillText(line.sig, pv_x, 0);
    ctx.translate(0, 0.2 * ln_h);
  }
  ctx.restore();
};

/*
 * triangular_weights
 * Returns an array of length n containing normalized weights.
 *
 */
function triangular_weights(n) {
  "use strict";
  var weights, half, half_i, sum, i, unscaled_weight;
  weights = [];
  half = n/2;
  half_i = Math.floor(half);
  sum = 0;
  for (i = 0; i < half_i; i++) {
    unscaled_weight = (i + 0.5) / half;
    weights[i] = unscaled_weight;
    weights[n - i -1] = unscaled_weight;
    sum += 2 * unscaled_weight;
  }
  if (n % 2 == 1) {
    weights[half_i] = 1;
    sum += 1;
  }
  // normalize
  for (i = 0; i < n; i++) {
    weights[i] /= sum;
  }
  return weights;
}

/*
 * uniform_weights
 * Returns an array of length n containing normalized weights.
 *
 */
function uniform_weights(n) {
  "use strict";
  var weights, weight, i;
  weights = [];
  weight = 1.0 / n;
  for (i = 0; i < n; i++) {
    weights[i] = weight;
  }
  return weights;
}
</script>
    <script>
      // 
      // return true if any part of the passed element is visible in the viewport
      //
      function element_in_viewport(elem) {
        var rect;
        try {
          rect = elem.getBoundingClientRect();
        } catch (e) {
          return false;
        }
        return (
            rect.top < (window.innerHeight || document.body.clientHeight) &&
            rect.bottom > 0 &&
            rect.left < (window.innerWidth || document.body.clientWidth) &&
            rect.right > 0
            );
      }

      //
      // Functions to delay a drawing task until it is required or it would not lag the display to do so
      //

      // a list of items still to be drawn
      var drawable_list = [];
      // the delay between drawing objects that are not currently visible
      var draw_delay = 1;
      // the delay after a user interaction
      var user_delay = 300;
      // the delay after a user has stopped scrolling and is viewing the stuff drawn on the current page
      var stop_delay = 300;
      // the timer handle; allows resetting of the timer after user interactions
      var draw_timer = null;

      //
      // Drawable
      //
      // elem - a page element which defines the position on the page that drawing is to be done
      // task - an object with the method run which takes care of painting the object
      //
      var Drawable = function(elem, task) {
        this.elem = elem;
        this.task = task;
      }

      //
      // Drawable.is_visible
      //
      // Determines if the element is visible in the viewport
      //
      Drawable.prototype.is_visible = function() {
        return element_in_viewport(this.elem);
      }

      //
      // Drawable.run
      //
      // Run the task held by the drawable
      Drawable.prototype.run = function() {
        if (this.task) this.task.run();
        this.task = null;
      }

      //
      // Drawable.run
      //
      // Run the task iff visible
      // returns true if the task ran or has already run
      Drawable.prototype.run_visible = function() {
        if (this.task) {
          if (element_in_viewport(this.elem)) {
            this.task.run();
            this.task = null;
            return true;
          }
          return false;
        } else {
          return true;
        }
      }

      //
      // draw_on_screen
      //
      // Checks each drawable object and draws those on screen.
      //
      function draw_on_screen() {
        var found = false;
        for (var i = 0; i < drawable_list.length; i++) {
          if (drawable_list[i].run_visible()) {
            drawable_list.splice(i--, 1);
            found = true;
          }
        }
        return found;
      }

      //
      // process_draw_tasks
      //
      // Called on a delay to process the next available
      // draw task.
      //
      function process_draw_tasks() {
        var delay = draw_delay;
        draw_timer = null;
        if (drawable_list.length == 0) return; //no more tasks
        if (draw_on_screen()) {
          delay = stop_delay; //give the user a chance to scroll
        } else {
          //get next task
          var drawable = drawable_list.shift();
          drawable.task.run();
        }
        //allow UI updates between tasks
        draw_timer = window.setTimeout("process_draw_tasks()", delay);
      }

      //
      // delayed_process_draw_tasks
      //
      // Call process_draw_tasks after a short delay.
      // The delay serves to group multiple redundant events.       
      // Should be set as event handler for onscroll and onresize.
      //
      function delayed_process_draw_tasks() {
        //reset the timer
        if (drawable_list.length > 0) { 
          if (draw_timer != null) clearTimeout(draw_timer);
          draw_timer = window.setTimeout("process_draw_tasks()", user_delay);
        }
      }

      //
      // add_draw_task
      //
      // Add a drawing task to be called immediately if it is
      // visible, or to be called on a delay to reduce stuttering
      // effect on the web browser.
      function add_draw_task(elem, task) {
        drawable = new Drawable(elem, task);
        if (drawable.is_visible()) {
          task.run();
        } else {
          drawable_list.push(drawable);
          //reset timer
          if (draw_timer != null) clearTimeout(draw_timer);
          draw_timer = window.setTimeout("process_draw_tasks()", user_delay);
        }
      }

</script>
    <script>
//
// simple-shared-doc.js
//
// Function to replace the innerHTML of element "id" with the HTML indicated by "doc_type".
// Easier to read and update than the more flexible approach in shared-doc.js. 
//
function print_doc(id, doc_type) {
  var html;
  switch (doc_type) {
    case 'motif-consensus':
      html = `
	<p id="consensus_doc"> 
	   A <b>consensus sequence</b> is constructed from each column in a
	   motif's frequency matrix using the <b>"50% rule"</b>
	   as follows:
	</p>
	<ol>
	  <li>The letter frequencies in the column are sorted in decreasing order.</li>
	  <li>Letters with frequency less 50% of the maximum are discarded.</li>
	  <li>The letter used in this position in the consensus sequence is determined
	  by the first rule below that applies:</li>
	  <ul>
	    <li>If there is only one letter left, or if the remaining letters exactly match
	    an ambiguous symbol in the alphabet, the <b>letter</b> or <b>ambiguous symbol</b>,
	    respectively, is used.</li>
	    <li>Otherwise, if the remaining set contains at least 50% of the core
	    symbols in the alphabet, the alphabet's <b>wildcard</b>
	    (e.g., "N" for DNA or RNA, and "X" for protein) is used.</li>
	    <li>Otherwise, the letter with the <b>maximum frequency</b> is used.</li>
	  </ul>
	</ol>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'ame-results-header':
      html = `
	<p>
          AME outputs a tab-separated values (TSV) file ('ame.tsv') that contains one line for each motif
	  found to be significantly enriched.
	  The lines are sorted in order of decreasing statistical significance.
          The first line contains the (tab-separated) names of the fields.
	  Your command line is given at the end of the file in a comment line starting with the
	  character '#'.
	</p>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'ame-results-table':
      html = `
	<p>
	  The <a href="` + site_url + `/doc/ame-output-format.html#tsv_results">AME Results TSV Format</a> 
	  differs depending on the choice of method for measuring motif enrichment, as shown in the following table. 
	</p>
	<table style="width:100%" border=1>
	  <tr>
	    <th>Method</th>
	    <th colspan=19>Output Columns</th>
	  </tr>
	  <tr>
	    <th></th> 
	    <th>1</th>
	    <th>2</th>
	    <th>3</th>
	    <th>4</th>
	    <th>5</th>
	    <th>6</th>
	    <th>7</th>
	    <th>8</th>
	    <th>9</th>
	    <th>10</th>
	    <th>11</th>
	    <th>12</th>
	    <th>13 </th>
	    <th>14 </th>
	    <th>15 </th>
	    <th>16 </th>
	    <th>17 </th>
	    <th>18 </th>
	    <th>19 </th>
	  </tr>
	  <tr>
	    <td>fisher</td>
	    <td>rank </td>
	    <td>motif_DB </td>
	    <td>motif_ID </td>
	    <td>motif_alt_ID </td>
	    <td>consensus </td>
	    <td>p-value </td>
	    <td>adj_p-value </td>
	    <td>E-value</td>
	    <td>tests </td>
	    <td>FASTA_max </td>
	    <td>pos </td>
	    <td>neg </td>
	    <td>PWM_min</td>
	    <td>TP </td>
	    <td>%TP </td>
	    <td>FP </td>
	    <td>%FP </td>
	    </td> <td>
	    </td> <td>
	  </tr>
	  <tr>
	    <td>ranksum</td>
	    <td>rank </td>
	    <td>motif_DB </td>
	    <td>motif_ID </td>
	    <td>motif_alt_ID </td>
	    <td>consensus </td>
	    <td>p-value </td>
	    <td>adj_p-value </td>
	    <td>E-value</td>
	    <td>tests </td>
	    <td>FASTA_max </td>
	    <td>pos </td>
	    <td>neg</td>
	    <td>U </td>
	    <td>pleft </td>
	    <td>pright </td>
	    <td>pboth </td>
	    <td>adj_pleft </td>
	    <td>adj_pright </td>
	    <td>adj_both</td>
	  </tr>
	  <tr>
	    <td>3dmhg</td>
	    <td>rank </td>
	    <td>motif_DB </td>
	    <td>motif_ID </td>
	    <td>motif_alt_ID </td>
	    <td>consensus </td>
	    <td>p-value </td>
	    <td>adj_p-value </td>
	    <td>E-value</td>
	    <td>tests </td>
	    <td>FASTA_max </td>
	    <td>pos </td>
	    <td>neg</td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	  </tr>
	  <tr>
	    <td>4dmhg</td>
	    <td>rank </td>
	    <td>motif_DB </td>
	    <td>motif_ID </td>
	    <td>motif_alt_ID </td>
	    <td>consensus </td>
	    <td>p-value </td>
	    <td>adj_p-value </td>
	    <td>E-value</td>
	    <td>tests </td>
	    <td>FASTA_max </td>
	    <td>pos </td>
	    <td>neg</td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	  </tr>
	  <tr>
	    <td>pearson</td>
	    <td>rank </td>
	    <td>motif_DB </td>
	    <td>motif_ID </td>
	    <td>motif_alt_ID </td>
	    <td>consensus </td>
	    <td>p-value </td>
	    <td>adj_p-value </td>
	    <td>E-value</td>
	    <td>tests </td>
	    <td>Pearson_CC </td>
	    <td>mean_squared_error </td>
	    <td>slope </td>
	    <td>intercept</td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	  </tr>
	  <tr>
	    <td>spearman</td>
	    <td>rank </td>
	    <td>motif_DB </td>
	    <td>motif_ID </td>
	    <td>motif_alt_ID </td>
	    <td>consensus </td>
	    <td>p-value </td>
	    <td>adj_p-value </td>
	    <td>E-value</td>
	    <td>tests </td>
	    <td>Spearman_CC</td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	  </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'ame-results-description':
      html = `
        <p>
          The names and meanings of each of the fields in <a href="` + site_url + `/doc/ame-output-format.html#tsv_results">AME Results TSV Format</a>,
          which depend on the method of enrichment analysis you chose, are described below.
        </p>
        <table class="dark" style="width:100%" border=1>
	  <tr> <th>method</th> <th>field</th> <th>name</th> <th>contents</th> </tr>	
    	  <tr> <td>all</td> <td>1</td> <td>rank</td> <td>The rank of the significance of the motif in the sorted results.</td> </tr>
    	  <tr> <td>all</td> <td>2</td> <td>motif_DB</td> <td> ` + get_doc_text('motif-db', 'the motif.') + `</td> </tr>
    	  <tr> <td>all</td> <td>3</td> <td>motif_ID</td> <td> ` + get_doc_text('motif-id') + `</td> </tr>
    	  <tr> <td>all</td> <td>4</td> <td>motif_alt_ID</td> <td> ` + get_doc_text('motif-alt-id') + `</td> </tr>
    	  <tr> <td>all</td> <td>5</td> <td>consensus</td> <td> ` + get_doc_text('motif-cons') + `</td> </tr>
    	  <tr> <td>all</td> <td>6</td> <td>p-value</td> <td> ` + get_doc_text('ame-pvalue') + `</td> </tr>
    	  <tr> <td>all</td> <td>7</td> <td>adj_p-value</td> <td> ` + get_doc_text('ame-adj-pvalue') + `</td> </tr>
    	  <tr> <td>all</td> <td>8</td> <td>E-value</td> <td> ` + get_doc_text('ame-evalue') + `</td> </tr>
    	  <tr> <td>all</td> <td>9</td> <td>tests</td> <td>The number of tests performed; used in correcting the <i>p</i>-value</td> </tr>
	  <tr> <td colspan=4></td>
          <tr> <td>fisher, ranksum, 3dmhg, 4dmhg</td> <td>10</td> <td>FASTA_max</td> <td>The optimal threshold for <b>labeling</b> sequences as positive;
            sequences with FASTA score less than or equal to the threshold are labeled as positive;
            this field will be contain the number of primary sequences if you provided
            a control file (using option <code>--control</code>); this field will contain the size of the
            partition if you specified one (using option <code>--fix-partition</code>).</td> </tr>
          <tr> <td>fisher, ranksum, 3dmhg, 4dmhg</td> <td>11</td> <td>pos</td> <td>The number of sequences <b>labeled</b> as positive.</td> </tr>
          <tr> <td>fisher, ranksum, 3dmhg, 4dmhg</td> <td>12</td> <td>neg</td> <td>The number of sequences <b>labeled</b> as negative.</td> </tr>
	  <tr> <td colspan=4></td>
          <tr> <td>fisher</td> <td>13</td> <td>PWM_min</td> <td>The optimal threshold on PWM score for <b>classifying</b> sequences as positive;
                sequences with PWM score greater than or equal to the threshold are classified as positive.</td> </tr>
          <tr> <td>fisher</td> <td>14</td> <td>TP</td> <td>The number of true positive sequences: sequences both <b>labeled</b> and <b>classified</b> as positive</td> </tr>
          <tr> <td>fisher</td> <td>15</td> <td>%TP</td> <td>The percentage of true positive sequences: percentage of sequences <b>labeled</b> positive and <b>classified</b> as positive.</td> </tr>
          <tr> <td>fisher</td> <td>16</td> <td>FP</td> <td>The number of false positive sequences: sequences <b>labeled</b> negative but <b>classified</b> as positive.</td> </tr>
          <tr> <td>fisher</td> <td>17</td> <td>%TP</td> <td>The percentage of false positive sequences: sequences <b>labeled</b> negative but <b>classified</b> as positive.</td> </tr>
	  <tr> <td colspan=4></td>
          <tr> <td>ranksum</td> <td>13</td> <td>U</td> <td>The value of the Mann-Whitney <i>U</i> statistic.</td> </tr>
          <tr> <td>ranksum</td> <td>14</td> <td>pleft</td> <td>The left-tailed <i>p</i>-value of the rank-sum test.</td> </tr>
          <tr> <td>ranksum</td> <td>15</td> <td>pright</td> <td>The right-tailed <i>p</i>-value of the rank-sum test.</td> </tr>
          <tr> <td>ranksum</td> <td>16</td> <td>pboth</td> <td>The two-tailed <i>p</i>-value of the rank-sum test.</td> </tr>
          <tr> <td>ranksum</td> <td>17</td> <td>adj_pleft</td> <td>The left-tailed <i>p</i>-value of the rank-sum test, adjusted for multiple tests.</td> </tr>
          <tr> <td>ranksum</td> <td>18</td> <td>adj_pright</td> <td>The right-tailed <i>p</i>-value of the rank-sum test, adjusted for multiple tests.</td> </tr>
          <tr> <td>ranksum</td> <td>19</td> <td>adj_both</td> <td>The two-tailed <i>p</i>-value of the rank-sum test, adjusted for multiple tests.</td> </tr>
	  <tr> <td colspan=4></td>
	  <tr> <td>pearson</td> <td>10</td> <td>Pearson_CC</td> <td>The correlation coefficient of the PWM and FASTA scores of positive sequences.</td> </tr>
	  <tr> <td>pearson</td> <td>11</td> <td>mean_squared_error</td> <td>The mean-squared error of the regression line between PWM and FASTA scores.</td> </tr>
	  <tr> <td>pearson</td> <td>12</td> <td>slope</td> <td>The slope of the regression line.</td> </tr>
	  <tr> <td>pearson</td> <td>13</td> <td>intercept</td> <td>The y-intercept of the regression line.</td> </tr>
	  <tr> <td colspan=4></td>
	  <tr> <td>spearman</td> <td>10</td> <td>Spearman_CC</td> <td>The correlation coefficient of the PWM and FASTA ranks of positive sequences./td> </tr>
        </table>
	  </ul>
	</p>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'ame-sequences-tsv':
      html = `
        <p>AME outputs a tab-separated values (TSV) file ('sequences.tsv') containing one line for
	each sequence classified as 'positive' by AME for each significant motif.
        The first line contains the (tab-separated) names of the fields.
	The lines are grouped by motif, and groups are separated by a line
	starting with the character "#".
        </p>
        <p>
          The names and meanings of each of the fields in <a href="` + site_url + `/doc/ame-output-format.html#tsv_sequences">AME Significant Sequences TSV Format</a>,
          are described below.
        </p>
        <table class="dark" style="width:100%" border=1>
          <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
	  <tr> <td>1</td> <td>motif_DB</td> <td>` + get_doc_text('motif-db', 'the motif.') + `</td> </tr>
	  <tr> <td>2</td> <td>motif_ID</td> <td>the ID of the motif</td> </tr>
	  <tr> <td>3</td> <td>seq_ID</td> <td>the ID of the sequence</td> </tr>
	  <tr> <td>4</td> <td><i>label_score</i> (either FASTA_score or PWM_score)</td> <td>the value of the score used to label it as positive</td> </tr>
	  <tr> <td>5</td> <td><i>class_score</i> (either PWM_score or FASTA_score)</td> <td>the value of the score used to classify it as positive</td> </tr>
	  <tr> <td>6</td> <td>class</td> <td>whether the sequence is a true positive, 'tp', or a false positive, 'fp'</td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'centrimo-results-tsv':
      html = `
	<p>
          CentriMo outputs a tab-separated values (TSV) file ('centrimo.tsv') that contains one line for each 
	  region found to be significantly enriched for a motif.
	  The lines are sorted in order of decreasing statistical significance.
          The first line contains the (tab-separated) names of the fields.
          Your command line is given at the end of the file in a comment line starting with the
          character '#'.
	</p>
	<p>
          The names and meanings of each of the fields in <a href="` + site_url + `/doc/centrimo-output-format.html#tsv_results">CentriMo Results TSV Format</a>,
          which depend on whether or not you provide control sequences to CentriMo, are described below.
	</p>
        <table class="dark" style="width:100%" border=1>
          <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
	  <tr> <td>1</td> <td>db_index</td> <td>The index of the motif file that contains the motif.  Motif
	      files are numbered in the order the appeared in the command line.</td> </tr>
	  <tr> <td>2</td> <td>motif_id</td> <td> ` + get_doc_text('motif-id') + `
	      If more than one motif has the same ID, CentriMo uses only the first such motif.
	      The name is single-quoted and preceded with '+' or '-' if you scanned separately with 
	      the reverse complement motif (using the <code>--sep</code> option).</td> </tr>
	  <tr> <td>3</td> <td>motif_alt_id</td> <td> ` + get_doc_text('motif-alt-id') + `</td> </tr>
	  <tr> <td>4</td> <td>consensus</td> <td> ` + get_doc_text('motif-cons') + `</td> </tr>
	  <tr> <td>5</td> <td>E-value</td> <td> ` + get_doc_text('centrimo-evalue') + `</td> </tr>
	  <tr> <td>6</td> <td>adj_p-value</td> <td> ` + get_doc_text('centrimo-adj-pvalue') + `
	      By default, a <i>p</i>-value is calculated by using the one-tailed binomial
	      test on the number of sequences with a match to the motif
	      that have their best match in the reported region;
              if you provided control sequences, the <i>p</i>-value of Fisher\'s exact test on the enrichment of 
              best matches in the positive sequences relative to the negative sequences is computed instead;
	      if you used the <code>--cd</code> option, the <i>p</i>-value is the probability that the average 
	      distance between the best site and the sequence center would be as low or lower than observed, 
	      computed using the cumulative Bates distribution, optimized over different score thresholds.
	      In all cases, the reported <i>p</i>-value has been adjusted for the number of regions
	      and/or score thresholds tested.</td> </tr>
	  <tr> <td>7</td> <td>log_adj_p-value</td> <td>Log of adjusted <i>p</i>-value.</td> </tr>
	  <tr> <td>8</td> <td>bin_location</td> <td>Location of the center of the most enriched region, or
		0 if you used the <code>--cd</code> option.
	  <tr> <td>9</td> <td>bin_width</td> <td> ` + get_doc_text('centrimo-bin-width') + `</td> </tr>
	  <tr> <td>10</td> <td>total_width</td> <td>The maximum number of regions possible for this motif
              <br>&nbsp;&nbsp;
	      round(sequence_length - motif_length + 1)/2,<br>
	      or the number of places the motif will fit if you used the <code>--cd</code> option.</td> </tr>
	  <tr> <td>11</td> <td>sites_in_bin</td> <td> ` + get_doc_text('centrimo-sites-in-bin') + `</td> </tr>
	  <tr> <td>12</td> <td>total_sites</td> <td>The number of sequences containing a match to the motif
	      above the score threshold.
	  <tr> <td>13</td> <td>p_success</td> <td>The probability of a random match falling into the enriched region:
	      <br>&nbsp;&nbsp;
	      bin_width / total_width</td> </tr>
	  <tr> <td>14</td> <td>p-value</td> <td>The uncorrected <i>p</i>-value before it gets adjusted for the
	      number of multiple tests to give the adjusted <i>p</i>-value.</td> </tr>
	  <tr> <td>15</td> <td>mult_tests</td> <td> ` + get_doc_text('centrimo-mult-tests') + `</td> </tr>
	  <tr> <th colspan=3>The following additional columns are present when you provide control sequences to CentriMo
	  (using the <code>--neg</code> option).</th> </tr>
	  <tr> <td>16</td> <td>neg_sites_in_bin</td> <td>The number of negative sequences where the best
	      match to the motif falls in the reported region.
	      This value is rounded but the underlying value may contain fractional counts.
	      Note: This number may be less than the number of negative have a best match in the region.
	      The reason for this is that a sequence may have many matches that score equally best.
	      If n matches have the best score in a sequence, 1/n is added to the
	      appropriate bin for each match.</td> </tr>
	  <tr> <td>17</td> <td>neg_sites</td> <td>The number of negative sequences containing a match to the
	      motif above the minimum score threshold.
	      When score optimization is enabled the score threshold may be raised
	      higher than the minimum.</td> </tr>
	  <tr> <td>18</td> <td>neg_adj_pvalue</td> <td>The probability that any tested region in the negative
	      sequences would be as enriched for best matches to this motif
	      according to the Binomial test.</td> </tr>
	  <tr> <td>19</td> <td>log_neg_adj_pvalue</td> <td>Log of negative adjusted <i>p</i>-value.</td> </tr>
	  <tr> <td>20</td> <td>fisher_adj_pvalue</td> <td>Fisher adjusted <i>p</i>-value before it gets adjusted for the
	      number of motifs in the input files(s).</td> </tr>
	  <tr> <td>21</td> <td>log_fisher_adj_pvalue</td> <td>Log of Fisher adjusted <i>p</i>-value.</td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'centrimo-sites-txt':
      html = `
	<p>
          CentriMo outputs a text file ('site_counts.txt') that contains,
	  for each motif, pairs of values (bin_position, site_count),
	  or triples of values (bin_position, site_count, neg_site_count) if
	  you provided control sequences to CentriMo.
	  This data can be used to plot the density of motif best matches (sites)
	  along the input sequences.  Fractional counts are possible if multiple (n)
	  bins contain the best match for a given sequence, with each bin  
	  receiving an incremental count of 1/n. 
	</p>
	<p>
	  The data for each motif begins with a header line with the format:
	  <br>&nbsp&nbsp
		DB &lt;db_number&gt; MOTIF &lt;id&gt; &lt;alt&gt;
	  </br>
	  where &lt;id&gt; and &lt;alt&gt; are as described above.
	  The following lines (up to the next header line) 
	  each contain a single value-pair or value-triple for the motif
	  named in the header line.
	</p>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'meme-chip-results-tsv':
      html = `
	<p>
          MEME-ChIP outputs a tab-separated values (TSV) file ('summary.tsv') that 
	  contains one line for each motif found by MEME-ChIP.
	  The lines are sorted in order of decreasing statistical significance.
	  The first line contains the (tab-separated) names of the fields.
	  Your command line is given at the end of the file in a comment line starting with the
	  character '#'.
	</p>
	<p>
          The names and meanings of the fields in the 
	  <a href="` + site_url + `/doc/meme-chip-output-format.html">MEME-ChIP Results Summary TSV Format</a> 
	  are described below. 
	</p>
        <table class="dark" style="width:100%" border=1>
          <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
          <tr> <td>1</td> <td>MOTIF_INDEX</td> <td>The index of the motif in the "Motifs in MEME text format" file ('combined.meme') 
		output by MEME-ChIP.</td> </tr>
          <tr> <td>2</td> <td>MOTIF_SOURCE</td> <td>The name of the program that found the <i>de novo</i> motif, or the
                name of the motif file containing the known motif.</td> </tr>
          <tr> <td>3</td> <td>MOTIF_ID</td> <td> ` + get_doc_text('motif-id') + `</td> </tr>
          <tr> <td>4</td> <td>ALT_ID</td> <td> ` + get_doc_text('motif-alt-id') + `</td> </tr>
          <tr> <td>5</td> <td>CONSENSUS</td> <td>The ID of the <i>de novo</i> motif, or a consensus sequence
                computed from the letter frequencies in the known motif
                (as described <a href="#consensus_doc">below</a>).</td> </tr>
          <tr> <td>6</td> <td>WIDTH</td> <td>The width of the motif.</td> </tr>
          <tr> <td>7</td> <td>SITES</td> <td>The number of sites reported by the <i>de novo</i> program, or the number
                of "Total Matches" reported by CentriMo.</td> </tr>
          <tr> <td>8</td> <td>E-VALUE</td> <td>The statistical significance of the motif.</td> </tr>
          <tr> <td>9</td> <td>E-VALUE_SOURCE</td> <td>The program that reported the <i>E</i>-value.</td> </tr>
          <tr> <td>10</td> <td>MOST_SIMILAR_MOTIF</td> <td>The known motif most similar to this motif according to Tomtom.</td> </tr>
          <tr> <td>11</td> <td>URL</td> <td>A link to a description of the most similar motif, or to the known motif.</td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'meme-chip-combined-motifs':
      html = `
        <p>
          MEME-ChIP outputs a text file ('combined.meme') containing all the significant motifs found by MEME-ChIP.
          The motifs are in <a href="` + site_url + `/doc/meme-format.html">Minimal MEME Motif format</a>, 
	  and their IDs correspond to the motif indices given in the "Summary in TSV Format" file ('summary.tsv').
        </p>
        </p>
          <b>Note:</b> The 'nsites=' and 'E=' fields in the motif headers are only
          relevant for the MEME and DREME motifs.  For known motifs, those values do
          not refer to the number of sites in the input sequences.
        </p>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'spamo-results-tsv':
      html = `
	<p>
          SpaMo outputs a tab-separated values (TSV) file ('spamo.tsv') that contains one line for each motif
	  found to be significantly enriched.
	  The lines are grouped by secondary motif and sorted in order of decreasing statistical significance.
          The first line contains the (tab-separated) names of the fields.
	  Your command line is given at the end of the file in a comment line starting with the character '#'.
	</p>
	<p>
	  The names and meanings of each of the fields in <a href="` + site_url + `/doc/spamo-output-format.html#results-tsv">SpaMo Results TSV Format</a> 
	  are described below. 
	</p>
	<table class="dark" style="width:100%" border=1>
	  <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
          <tr> <td>1</td> <td>prim_db</td> <td> ` + get_doc_text('motif-db', 'the primary motif.') + `</td> </tr>
          <tr> <td>2</td> <td>prim_id</td> <td> ` + get_doc_text('motif-id', 'primary') + `</td> </tr>
          <tr> <td>3</td> <td>prim_alt</td> <td> ` + get_doc_text('motif-alt-id', 'primary') + `</td> </tr>
          <tr> <td>4</td> <td>prim_cons</td> <td> ` + get_doc_text('motif-cons', 'primary') + `</td> </tr>
          <tr> <td>5</td> <td>sec_db</td> <td> ` + get_doc_text('motif-db', 'the secondary motif.') + `</td> </tr>
          <tr> <td>6</td> <td>sec_id</td> <td> ` + get_doc_text('motif-id', 'secondary') + `</td> </tr>
          <tr> <td>7</td> <td>sec_alt</td> <td> ` + get_doc_text('motif-alt-id', 'secondary') + `</td> </tr>
          <tr> <td>8</td> <td>sec_cons</td> <td> ` + get_doc_text('motif-cons', 'secondary') + `</td> </tr>
          <tr> <td>9</td> <td>trim_left</td> <td>Number of positions trimmed from left of secondary motif.</td> </tr>
          <tr> <td>10</td> <td>trim_right</td> <td>Number of positions trimmed from right of secondary motif.</td> </tr> 
          <tr> <th colspan=3>If the next three fields are not blank, the motif is redundant with a more significant ('parent') motif.</th> </tr>
          <tr> <td>11</td> <td>red_db</td> <td> ` + get_doc_text('motif-db', 'the parent motif.') + `</td> </tr>
          <tr> <td>12</td> <td>red_id</td> <td> ` + get_doc_text('motif-id', 'parent') + `</td> </tr>
          <tr> <td>13</td> <td>red_alt</td> <td> ` + get_doc_text('motif-alt-id', 'parent') + `</td> </tr>
          <tr> <td>14</td> <td>E-value</td> <td>The expected number motifs that would have least one spacing as enriched as the best spacing for this secondary. 
	    The <i>E</i>-value is the best spacing <i>p</i>-value multiplied by the number of motifs in the input database(s).</td> </tr>
          <tr> <td>15</td> <td>gap</td> <td>The distance between the edge of the primary and the (trimmed) secondary motif.</td> </tr>
          <tr> <td>16</td> <td>orient</td> <td>The (combination) of quadrants for which occurrences of this spacing are combined.</td> </tr>
          <tr> <td>17</td> <td>count</td> <td>The number of occurrences of the secondary motif with the given spacing and orientation to the primary motif.</td> </tr>
          <tr> <td>18</td> <td>total</td> <td>The total number of occurrences of the secondary motif within the margins around the best primary motif occurrence.</td> </tr>
          <tr> <td>19</td> <td>adj_p-value</td> <td>The <i>p</i>-value of the gap and orientation, adjusted for nine combinations of quadrants times the number of gaps tested (as controlled by the <code>-range</code> option).</td> </tr>
          <tr> <td>20</td> <td>p-value</td> <td>The <i>p</i>-value of the gap and orientation adjusted only for the number of gaps tested.</td> </tr>
        </table>
        <br>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'spamo-dumpseqs-tsv':
      html = `
	<p>
	  By specifying the options <code>--dumpseqs</code> or <code>--dumpsigs</code> 
	  you can have SpaMo create TSV (tab-separated values) files
	  describing the motif matches SpaMo used to make the histograms in its HTML output.
	  The files are named 
          '<code>seqs_&lt;primary_motif&gt;_&lt;secondary_db&gt;_&lt;secondary_motif&gt;.txt</code>'.
	  The rows in each file are sorted by sequence name.  
	  The first line contains the (tab-separated) names of the fields.
        </p>
	<p>
	  The names and meanings of each of the fields in <a href="` + site_url + `/doc/spamo-output-format.html#tsv_dumpseqs">SpaMo Dumpseqs TSV Format</a> 
	  are described below. 
        </p>
	<table class="dark" style="width:100%">
	  <tr><th>field</th><th>name</th><th>contents</th></tr>
	  <tr><td>1</td><td>matches</td><td>Trimmed lowercase sequence centered on primary match with matches in uppercase.</td></tr>
	  <tr><td>2</td><td>sec_pos</td><td>Position of the secondary match within the whole sequence.</td></tr>
	  <tr><td>3</td><td>pri_match</td><td>Sequence fragment that the primary matched.</td></tr>
	  <tr><td>4</td><td>pri_strand</td><td>Strand of the primary match (+/-).</td></tr>
	  <tr><td>5</td><td>sec_match</td><td>Sequence fragment that the secondary matched.</td></tr>
	  <tr><td>6</td><td>sec_strand</td><td>Strand of the secondary match (+/-).</td></tr>
	  <tr><td>7</td><td>same_opp</td><td>The primary match on the same (s) or opposite (o) strand as the secondary.</td></tr>
	  <tr><td>8</td><td>down_up</td><td>The secondary match is downstream (d) or upstream (u) of the primary.</td></tr>
	  <tr><td>9</td><td>gap</td><td>The gap between the primary and secondary matches.</td></tr>
	  <tr><td>10</td><td>seq_name</td><td>The name of the sequence.</td></tr>
	  <tr><td>11</td><td>adj_p-value</td><td>The <i>p</i>-value of the bin containing the match, adjusted for the number of bins.</td></tr>
	  <tr><th colspan="3">If the sequence names are in UCSC Genome Browser position
	  format (e.g., "chr5:36715616-36715623"), the following additional fields will be present:</th></tr>
	  <tr><td>12</td><td>pri_bed_chr</td><td>Position of primary match in BED coordinates.</td></tr>
	  <tr><td>13</td><td>pri_bed_start</td><td>"</td></tr>
	  <tr><td>14</td><td>pri_bed_end</td><td>"</td></tr>
	  <tr><td>15</td><td>pri_browser</td><td>Position of primary match in UCSC Genome Browser coordinates.</td></tr>
	  <tr><td>16</td><td>sec_bed_chr</td><td>Position of secondary match in BED coordinates.</td></tr>
	  <tr><td>16</td><td>sec_bed_start</td><td>"</td></tr>
	  <tr><td>16</td><td>sec_bed_end</td><td>"</td></tr>
	  <tr><td>19</td><td>sec_browser</td><td>Position of secondary match in UCSC Genome Browser coordinates.</td></tr>
	</table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'fimo-results-tsv':
      html = ` 
        <p>
          FIMO outputs a tab-separated values (TSV) file ('fimo.tsv') that contains one line for each
          significant match to a motif.
          The lines are sorted in order of decreasing statistical significance (increasing <i>p</i>-value).
          The first line contains the (tab-separated) names of the fields.
          Your command line is given at the end of the file in a comment line starting with the
          character '#'.
        </p>
	<p>
	  The names and meanings of each of the fields in <a href="` + site_url + `/doc/fimo-output-format.html#results-tsv">FIMO Results TSV Format</a> 
	  are described below. 
	</p>
	<table class="dark" style="width:100%" border=1>
	  <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
          <tr> <td>1</td> <td>motif_id</td> <td> ` + get_doc_text('motif-id') + `</td> </tr>
          <tr> <td>2</td> <td>motif_alt_id</td> <td> ` + get_doc_text('motif-alt-id') + `</td> </tr>
          <tr> <td>3</td> <td>sequence_name</td> <td> ` + get_doc_text('sequence-id') + ` --OR-- the `
	    + get_doc_text('sequence-name') + `</td> </tr>
          <tr> <td>4</td> <td>start</td> <td> ` + get_doc_text('match-start-seq', 'motif occurrence') + ` --OR-- `
            + get_doc_text('match-start-genomic', 'motif occurrence') 
            + get_doc_text('parse-genomic-coord', 'The latter case occurs when FIMO') + `</td> </tr>
          <tr> <td>5</td> <td>stop</td> <td> ` + get_doc_text('match-stop-seq', 'motif occurrence') + ` --OR-- `
            + get_doc_text('match-stop-genomic', 'motif occurrence') 
            + get_doc_text('parse-genomic-coord', 'The latter case occurs when FIMO') + `</td> </tr>
          <tr> <td>6</td> <td>strand</td> <td>The strand '<code>+</code>' indicates the motif matched the forward
	    strand, '<code>-</code>' the reverse strand, and '<code>.</code>'
	    indicates strand is not applicable (as for amino acid sequences).</td> </tr>
          <tr> <td>7</td> <td>score</td> <td>The score for the motif occurrence. `
            + get_doc_text('motif-match-score') + `</td> </tr>
          <tr> <td>8</td> <td>p-value</td> <td> The <i>p</i>-value of the motif occurrence. `
            + get_doc_text('motif-match-p-value') + `</td> </tr>
          <tr> <td>9</td> <td>q-value</td> <td>The q-value of the motif occurrence. `
            + get_doc_text('bh-q-value', 'FIMO') + ` <b>Note:</b> This column is empty if you used the <span class=popt>--text</span> switch.</td> </tr>
          <tr> <td>10</td> <td>sequence</td> <td>The region of the sequence matched to the motif.</td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'fimo-results-gff3':
      html = `
        <p>
          FIMO outputs a GFF3</a> file ('fimo.gff') that contains one line for each
          significant match to a motif.
        </p>
        <p>
	  The GFF3 format is described <a href="http://gmod.org/wiki/GFF3">here</a>.
	  The 'score' reported in the FIMO GFF3 output</a> (in column 6) is<br/>
	  &nbsp;&nbsp;&nbsp;&nbsp;<code>min(1000, -10*(log10(pvalue)))</code>, <br/>
	  and the 'display name' ('Name=' tag in column 9) is composed of the contents of three 
	  fields as follows <br/>
	  &nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;motif_id&gt;_&lt;sequence_name&gt;&lt;strand&gt;</code>.
        </p>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'gomo-results-tsv':
      html = `
        <p>
          GOMo outputs a tab-separated values (TSV) file ('gomo.tsv') that contains one line for each 
	  motif-GO-term pair found to be significantly enriched.
          The lines are grouped by motif and sorted in order of decreasing statistical significance.
          The first line contains the (tab-separated) names of the fields.
          Your command line is given at the end of the file in a comment line starting with the character '#'.
        </p>
        <p>
          The names and meanings of each of the fields in <a href="` + site_url + `/doc/gomo-output-format.html#results-tsv">GOMo Results TSV Format</a>
          are described below.
        </p>
        <table class="dark" style="width:100%" border=1>
          <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
          <tr> <td>1</td> <td>Motif_Identifier</td> <td> ` + get_doc_text('motif-id') + ` </td> </tr> 
          <tr> <td>2</td> <td>GO_Term_Identifier</td> <td> ` + get_doc_text('gomo-go-term') + ` </td> </tr>
          <tr> <td>3</td> <td>GOMo_Score</td> <td> ` + get_doc_text('gomo-score') + ` </td> </tr>
          <tr> <td>4</td> <td>p-value</td> <td> ` + get_doc_text('gomo-p-value') + ` </td> </tr>
          <tr> <td>5</td> <td>q-value</td> <td> ` + get_doc_text('bh-q-value', 'GOMo') + ` </td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'gomo-results-xml':
      html = `
	<p>
	GOMo outputs an XML file ('gomo.xml') with the following format.
	</p>
	<table class="bordertable" border="1">
	  <tr>
	    <th>Tag</th><th>Child of</th><th>Description</th>
	  </tr>
	  <tr>
	    <td >&lt;gomo&gt;</td><td >Nothing</td>
	    <td>
	      Information about this run of GOMo.
	      <ul>
		<li>version - The version of GOMo that generated the XML file.</li>
		<li>release - The release date of the version that generated the XML.</li>
	      </ul>
	    </td>
	  </tr>
	  <tr>
	    <td >&lt;program&gt;</td>
	    <td >&lt;gomo&gt;</td>
	    <td>
	      Information about the state of the program when it ran.<br />
	      <ul>
		<li>name - name of the program.</li>
		<li>cmd - the command line passed to the program.</li>
		<li>gene_url - the url used to lookup further information on the gene ids. 
		The url has ampersands (&amp;) converted into <b>&amp;amp;</b> and the place where
		  the gene ID should be replaced by <b>!!GENEID!!</b> .</li>
		<li>outdir - the output directory that the program wrote to.</li>
		<li>clobber - true if GOMo was allowed to overwrite the output directory.</li>
		<li>text_only - true if GOMo wrote to stdout, in which case this file would
		  not exist so it must be false.</li>
		<li>use_e_values - true if GOMo used <i>E</i>-values (converted from <i>p</i>-values) as 
		  input scores, false if GOMo used gene scores.</li>
		<li>score_e_thresh - if GOMo used <i>E</i>-values then this is the threshold that 
		  GOMo assumed the worst <i>E</i>-value (<i>p</i>-value = 1.0) for the gene to smooth out noise.</li>
		<li>min_gene_count - the minimum number of genes that a GO term was annotated 
		  with before GOMo would calculate a score for it.</li>
		<li>motifs - if present then a space delimited list of the motifs that GOMo
		  calculated a score for, otherwise GOMo scored all motifs.</li>
		<li>shuffle_scores - the number of times GOMo generated a shuffled mapping of
		  gene id to gene id to be used to generate scores from the null model.</li>
		<li>q_threshold - GOMo filtered the results to only show those with a better
		(smaller) q-value.</li>
	      </ul>
	    </td>
	  </tr>
	  <tr>
	    <td>&lt;gomapfile&gt;</td>
	    <td>&lt;program&gt;</td>
	    <td>
	      Information about the GO mapping file.<br />
	      <ul>
		<li>path - the path to the mapping file.</li>
	      </ul>
	    </td>
	  </tr>
	  <tr>
	    <td>&lt;seqscorefile&gt;</td>
	    <td>&lt;program&gt;</td>
	    <td>
	      Information about the sequence scoring file.<br />
	      <ul>
		<li>path - the path to the sequence scoring file.</li>
	      </ul>
	    </td>
	  </tr>
	  <tr>
	    <td>&lt;motif&gt;</td>
	    <td>&lt;gomo&gt;</td>
	    <td>
	      Information about the motif.<br />
	      <ul>
		<li>id - the motif identifier.</li>
		<li>genecount - the number of scored sequences that were used to compute the result.</li>
	      </ul>
	    </td>
	  </tr>
	  <tr>
	    <td>&lt;goterm&gt;</td>
	    <td>&lt;motif&gt;</td>
	    <td>
	      Information about the GO term.<br />
	      <ul>
		<li>id - the GO identifier.</li>
		<li>score - the geometric mean across all species of the rank-sum test <i>p</i>-value.</li>
		<li>pvalue - the empirically calculated <i>p</i>-value.</li>
		<li>qvalue - the empirically calculated q-value.</li>
		<li>annotated - the number of genes annotated with the go term.</li>
		<li>group - the subgroup that the term belongs to. For the Gene Ontology 
		    b = biological process, c = cellular component and m = molecular function.</li>
		<li>nabove - the number of more general terms that link to this one.</li>
		<li>nbelow - the number of more specific terms that link from this one.</li>
		<li>implied - is the go term implied by other significant go terms? 
		  Allows values 'y', 'n' or 'u' (default) for yes, no or unknown.</li>
		<li>description - the GO term description.</li>
	      </ul>
	    </td>
	  </tr>
	  <tr>
	    <td>&lt;gene&gt;</td>
	    <td>&lt;goterm&gt;</td>
	    <td>
	      Information about the GO term's annotated genes for the primary species.<br />
	      <ul>
		<li>id - the gene identifier.</li>
		<li>rank - the rank of the scored gene.</li>
	      </ul>
	    </td>
	  </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'mcast-results-tsv':
      html = ` 
        <p>
          MCAST outputs a tab-separated values (TSV) file ('mcast.tsv') that contains one line for each
          significant match of a cluster of motifs to a sequence region.
          The lines are sorted in order of decreasing statistical significance (increasing <i>p</i>-value).
          The first line contains the (tab-separated) names of the fields.
          Your command line is given at the end of the file in a comment line starting with the
          character '#'.
        </p>
	<p>
	  The names and meanings of each of the fields in 
          <a href="` + site_url + `/doc/mcast-output-format.html#results-tsv">MCAST Results TSV Format</a> 
	  are described below. 
	</p>
	<table class="dark" style="width:100%" border=1>
	  <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
          <tr> <td>1</td> <td>pattern_name</td> <td>A unique name that MCAST generates for the match. </td> </tr>
          <tr> <td>2</td> <td>sequence_name</td> <td> ` + get_doc_text('sequence-id') + ` --OR-- the `
	    + get_doc_text('sequence-name') + `</td> </tr>
          <tr> <td>3</td> <td>start</td> <td> ` + get_doc_text('match-start-seq', 'matched sequence region') + ` --OR-- `
            + get_doc_text('match-start-genomic', 'motif occurrence')
            + get_doc_text('parse-genomic-coord', 'The latter case occurs when MCAST') + `</td> </tr>
          <tr> <td>4</td> <td>stop</td> <td> ` + get_doc_text('match-stop-seq', 'matched sequence region') + ` --OR-- `
            + get_doc_text('match-stop-genomic', 'motif occurrence')
            + get_doc_text('parse-genomic-coord', 'The latter case occurs when MCAST') + `</td> </tr>
          <tr> <td>5</td> <td>score</td> <td> ` + get_doc_text('mcast-cluster-score') + ` </td> </tr>
          <tr> <td>6</td> <td>p-value</td> <td> ` + get_doc_text('mcast-cluster-p-value') + ` </td> </tr>
          <tr> <td>7</td> <td>E-value</td> <td> ` + get_doc_text('mcast-cluster-E-value') + ` </td> </tr>
          <tr> <td>8</td> <td>q-value</td> <td> ` + get_doc_text('bh-q-value', 'MCAST') + ` 
	    <b>Note:</b> This column is empty if you used the <span class=popt>--text</span> switch.</td> </tr>
          <tr> <td>9</td> <td>sequence</td> <td>The region of the sequence matched to the motif cluster.</td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'mcast-results-gff3':
      html = `
        <p>
          MCAST outputs a GFF3</a> file ('mcast.gff') that contains one line for each
          significant match to a motif cluster.
        </p>
        <p>
	  The GFF3 format is described <a href="http://gmod.org/wiki/GFF3">here</a>.
	  The 'score' reported in the MCAST GFF3 output</a> (in column 6) is<br/>
	  &nbsp;&nbsp;&nbsp;&nbsp;<code>min(1000, -10*(log10(pvalue)))</code>, <br/>
	  and the 'unique identifier' ('ID=' tag in column 9) is the value of the
	  &lt;pattern_name&gt; field in the MCAST results TSV format.  Following the
	  unique identifier in column 9, the <i>p</i>-value, <i>E</i>-value and q-value
	  of the match are given.
        </p>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'tomtom-results-tsv':
      html = `
	<p>
          Tomtom outputs a tab-separated values (TSV) file ('tomtom.tsv') that contains one line for each motif
	  found to be significantly enriched.
	  The lines are grouped by query motif and sorted in order of decreasing statistical significance.
          The first line contains the (tab-separated) names of the fields.
	  Your command line is given at the end of the file in a comment line starting with the character '#'.
	</p>
	<p>
	  The names and meanings of each of the fields in <a href="` + site_url + `/doc/tomtom-output-format.html#results-tsv">Tomtom Results TSV Format</a> 
	  are described below. 
	</p>
	<table class="dark" style="width:100%" border=1>
	  <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
          <tr> <td>1</td> <td>Query_ID</td> <td> ` + get_doc_text('motif-id', 'query') + `</td> </tr>
          <tr> <td>2</td> <td>Target_ID</td> <td> ` + get_doc_text('motif-id', 'target') + `</td> </tr>
          <tr> <td>3</td> <td>Optimal_offset</td> <td> ` + get_doc_text('tomtom-offset') + `</td> </tr>
          <tr> <td>4</td> <td>p-value</td> <td> ` + get_doc_text('tomtom-p-value') + `</td> </tr>
          <tr> <td>5</td> <td>E-value</td> <td> ` + get_doc_text('tomtom-E-value') + `</td> </tr>
          <tr> <td>6</td> <td>q-value</td> <td> ` + get_doc_text('bh-q-value', 'Tomtom') + `</td> </tr>
          <tr> <td>7</td> <td>Overlap</td> <td> ` + get_doc_text('tomtom-overlap') + `</td> </tr>
          <tr> <td>8</td> <td>Query_consensus</td> <td>A consensus sequence
                computed from the letter frequencies in the query motif
                (as described <a href="#consensus_doc">below</a>).</td> </tr>
          <tr> <td>9</td> <td>Target_consensus</td> <td>A consensus sequence
                computed from the letter frequencies in the target motif
                (as described <a href="#consensus_doc">below</a>).</td> </tr>
          <tr> <td>10</td> <td>Orientation</td> <td> ` + get_doc_text('tomtom-orientation', "<br>A value of '+' means that the target motif is as it appears in the database. A value of '-' means that the reverse complement of the target motif is shown.") + `</td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    default:
      html = "Error--Unrecognized doc_type: " + doc_type;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
  }
} // print_doc

//
// Function to return the HTML text of a given type.
// This function can be used directly to document the output format (xx-output-format.html)
// and indirectly via print_doc_para for help pop-ups in the actual output HTML,
// to prevent duplication of documentation.
//
function get_doc_text(doc_type, extra) {
  var html;
  if (extra == undefined) {extra = ""};

  switch (doc_type) {

    // shared
    case 'motif-db':
      return(`
	The name of a file of motifs ("motif database file") that contains ` + extra + `
      `);
    case 'motif-id':
      return(`
	The name of the ` + extra + ` motif, which is unique in the motif database file.
      `);
    case 'motif-alt-id':
      return(`
	An alternate name for the ` + extra + ` motif, which may be provided in the motif database file.
      `);
    case 'motif-width':
      return(`
	The width of the motif. No gaps are allowed in motifs supplied to ` + extra + `
        as it only works for motifs of a fixed width.
      `);
    case 'motif-cons':
      return(`
	A consensus sequence computed from the ` + extra + ` motif (as described <a href="#consensus_doc">below</a>).
      `);
    case 'motif-match-score':
     return(`
	The score for the match of a position in a sequence to a motif is
	computed by summing the appropriate entry from each column of the
	position-dependent scoring matrix that represents the motif. ` + extra + `
     `);
    case 'motif-match-p-value':
      return(`
	The <i>p</i>-value of a motif match is the probability of a single random
	subsequence of the length of the motif
	<a href="javascript:help_refine('pop_motif_match_score')">scoring</a>
	at least as well as the observed match.
      `);
    case 'bh-q-value-method':
      return(`
        ` + extra + ` estimates q-values from all the match <i>p</i>-values 
	using the method proposed by Benjamini & Hochberg (<i>Journal of the Royal Statistical Society B</i>, 57:289-300, 1995).
	See also Storey JD, Tibshirani R. Statistical significance for
	genome-wide studies, <i>Proc. Natl. Acad. Sci. USA</i> (2003) <b>100</b>:9440&ndash;9445.
      `);
    case 'bh-q-value':
      return(`
	The minimum False Discovery Rate (FDR) required to consider this match significant.</br>` + get_doc_text('bh-q-value-method', extra) + `
      `);
    case 'sdb-name':
      return(`
	The name of the (FASTA) sequence database file.
      `);
    case 'sdb-psp':
      return(`
	The name of the position specific priors (PSP) file.
      `);
    case 'sdb-dist':
      return(`
	The name of the binned distribution of priors file.
      `);
    case 'sdb-count':
      return(`
	The number of sequences in the database.
      `);
    case 'sdb-letters':
      return(`
	The number of letters in the sequence database.
      `);
    case 'lastmod':
      return(`
	The date of the last modification to the ` + extra + ` database.
      `);
    case 'sequence-id':
      return(`
        The identifier of the sequence (from the FASTA sequence header line)` + extra + `
      `);
    case 'sequence-name':
      return(`
	` + extra + `name of the sequence extracted from the sequence identifier (in the FASTA sequence header line).<br>
	When you use the <code>--parse-genomic--coord</code> option, the sequence name ends at the
	first colon ':' (if any) present in the sequence\'s FASTA identifier.  Typically this is the
	chromosome or contig name.  With the <code>--parse-genomic--coord</code> option,
	the start and stop positions are in 0-based coordinates relative to the sequence start given 
	in the FASTA sequence identifier (just after the sequence name).</td> </tr>
      `);
    case 'sequence-desc':
      return(`
        The description appearing after the identifier of the sequence in the FASTA header line.
      `);
    case 'sequence-name':
    case 'alph-name':
      return(`
	The name of the alphabet symbol.
      `);
    case 'alph-bg':
      return(`
	The frequency of the alphabet symbol as defined by the background model.
      `);
    case 'match-start-seq':
      return(`
	The start position of the ` + extra + `; 1-based sequence coordinates.
      `);
    case 'match-stop-seq':
      return(`
	The end position of the ` + extra + `; 1-based sequence coordinates.
      `);
    case 'match-start-genomic':
      return(`
	The start position of the ` + extra + `; genomic coordinates.
      `);
    case 'match-stop-genomic':
      return(`
	The end position of the ` + extra + `; genomic coordinates.
      `);
    case 'parse-genomic-coord':
      return(`
	` + extra + ` was run with the <code>--parse-genomic-coord</code> option
	and has split the sequence identifier into sequence name, sequence start and sequence end 
	in genomic coordinates.
      `);

    // AME
    case 'ame-pvalue':
      return(`
	The optimal enrichment <i>p</i>-value of the motif according to the statistical test;
	not adjusted for multiple tests.
      `);
    case 'ame-adj-pvalue':
      return(`
	The optimal enrichment <i>p</i>-value of the motif according to the statistical test,
        adjusted for multiple tests using a Bonferroni correction. ` + extra + `
	If the best <i>p</i>-value is <i>p</i> before adjustment,
        and the number of multiple tests is <i>n</i>, then the adjusted
        <i>p</i>-value is 1 - (1-<i>p</i>)<i><sup>n</sup></i>.
      `);
    case 'ame-evalue':
      return(`
	The expected number of motifs that would be as enriched in the
        (primary) sequences as this one.  The <i>E</i>-value is the adjusted <i>p</i>-value
        multiplied by the number of motifs in the motif file(s).
      `);

    // CentriMo
    case 'centrimo-adj-pvalue':
      return(`
        The statistical significance of the enrichment of the motif, adjusted for multiple tests. ` + extra + `
      `);
    case 'centrimo-evalue':
      var evalue_html = `
        at least one region as enriched for best matches to the motif as the reported region
	(or would have optimal average distance to the sequence center as low as observed, 
	if you used the <code>--cd</code> option).
      `;
      return(`
	The expected number motifs that would have ` + (extra ? extra : evalue_html) + `
	The <i>E</i>-value is the adjusted <i>p</i>-value multiplied by the number of motifs in the
	input files(s).</td> </tr>
      `);
    case 'centrimo-bin-width':
      return(`
        The width (in sequence positions) of the most enriched region (default),
        <b>or</b> two times the average distance between the center of the best site
        and the sequence center if you used the option <code>--cd</code>.
        A best match to the motif is counted as being in the region if
        the center of the motif falls in the region.
      `);
    case 'centrimo-sites-in-bin':
      return(`
	The number of (positive) sequences whose best match to the motif `
	+ (extra ? extra : "falls in the reported region (default) or anywhere in the sequence (if you used the option <code>--cd</code>).") + `
	<br>Note: This number may be less than the number of
	(positive) sequences that have a best match in the region.
	The reason for this is that a sequence may have many matches that score
	equally best.  If <i>n</i> matches have the best score in a sequence, 1/<i>n</i> is added to the
	appropriate bin for each match.</td> </tr>
      `);
    case 'centrimo-mult-tests':
      return(`
	This is the number of multiple tests (<i>n</i>) done for this motif.
	It was used to adjust the <i>p</i>-value of a region for
	multiple tests using the formula:
	<br>&nbsp;&nbsp;
	  <i>p</i>' = 1 - (1-<i>p</i>)<sup><i>n</i></sup> where <i>p</i> is the unadjusted <i>p</i>-value.
	<br>
	The number of multiple tests is the number of regions
	considered times the number of score thresholds considered.
	It depends on the motif length, sequence length, and the type of
	optimizations being done (central enrichment, local enrichment, central distance or
	score optimization).</td> </tr>
      `);

    // GOMo
    case 'gomo-go-term':
      return(`
        The Gene Ontology Consortium term for a specific role or locality.
        Used for annotating genes with their functions.
      `);
    case 'gomo-score':
      return( `
	A score generated as the <a href="https://en.wikipedia.org/wiki/Geometric_mean">
	geometric mean</a> of <a href="https://en.wikipedia.org/wiki/Mann-Whitney_U_test">rank-sum test(s)</a> 
	for the particular Gene Ontology term. The two groups compared by the rank-sum test are scores of genes annotated 
	with the GO term and scores of genes not annotated with the GO term.</td> </tr>
      `);
    case 'gomo-p-value':
      return( `
	An empirically generated <i>p</i>-value for the enrichment of the GO term.<br>
	The null hypothesis is that by shuffling the labels on gene scores, 
	any possible association between the set of genes that a GO term annotates is destroyed. 
	A large number of scores are generated using the null hypothesis and the number of null 
	hypothesis scores that are better than each of the real scores is summed and then divided 
	by the total null hypothesis scores generated to calculate a <i>p</i>-value.</td> </tr>
      `);

    // MAST

    // MCAST
    case 'mcast-cluster-score':
      return( `
        The score that the hidden Markov model created by MCAST assigned to the motif cluster.<br>
        This is the sum of the scores of the individual motif matches in the cluster, plus a
        gap penalty, <i>g</i>, multiplied by the total size of the inter-motif gaps
        in the cluster.  Individual motif match scores are log2(<i>P(s)/p</i>), where <i>s</i> is the 
        <a href="javascript:help_refine('pop_motif_match_score')">log-odds score</a> 
        of the motif match, <i>P(s)</i> is the 
        <a href="javascript:help_refine('pop_motif_match_pvalue')"><i>p</i>-value</a> 
	of the motif match, and <i>p</i> is the user-specified <i>p</i>-value threshold (default: 0.0005).
        <div class="active" id="pop_motif_match_score_act"></div>
        <div class="active" id="pop_motif_match_pvalue_act"></div>
      `);
    case 'mcast-cluster-p-value':
      return( `
	The <i>p</i>-value of the motif cluster score.<br>
	MCAST estimates <i>p</i>-values by fitting an exponential distribution
	to the observed motif cluster scores.
      `);
    case 'mcast-cluster-E-value':
      return( `
        The <i>E</i>-value of the motif cluster score.<br>
	The <i>E</i>-value is an estimate of the <i>number</i> of false positive matches
	with <i>p</i>-values at least as good as this match\'s.  
        MCAST estimates this by multiplying the motif cluster score <i>p</i>-value
        times the (estimated) number of random matches found in the search.
      `);

    // Tomtom
    case 'tomtom-offset':
      return( `
        The offset of the query motif relative to the target motif in the optimal alignment.<br>
 	A positive value indicates the query is shifted right.
      `);
    case 'tomtom-p-value':
      return( `
        The probability that a random motif of the same width as the target would have an 
	optimal alignment with a match score as good or better than the target's.<br>
	Tomtom estimates the <i>p</i>-value using a null model consisting of sampling
	motif columns from all the columns in the set of target motifs.
      `);
    case 'tomtom-E-value':
      return( `
	The expected number of false positives in the matches up to this point.<br>
	Tomtom estimates the <i>E</i>-value by multiplying the <i>p</i>-value by
	the total number of target motifs in all the target databases.
      `);
    case 'tomtom-overlap':
      return( `
	The number of motif columns that overlap in the optimal alignment.
      `);
    case 'tomtom-orientation':
      return( `
	The orientation of the target motif that gave the optimal alignment. ` + extra + `
      `);
  }

} // get_doc_text

//
// Function to replace the innerHTML of element "id" with an HTML paragraph
// containing the text for 'doc_type', which is known to function get_doc_text.
// This function can be used in help pop-ups.
//
function print_doc_para(id, doc_type, extra) {
  html = `<p>` + get_doc_text(doc_type, extra) + `</p>`; 
  document.getElementById(id).insertAdjacentHTML('beforeend', html);
} // print_doc_para
</script>
    <script>
function make_alpha_bg_table(alph, freqs) {
  function colour_symbol(index) {
    var span = document.createElement("span");
    span.appendChild(document.createTextNode(alph.get_symbol(index)));
    span.style.color = alph.get_colour(index);
    span.className = "alpha_symbol";
    return span;
  }
  var table, thead, tbody, row, th, span, i;
  // create table
  table = document.createElement("table");
  table.className = "alpha_bg_table";
  // create header
  thead = document.createElement("thead");
  table.appendChild(thead);
  row = thead.insertRow(thead.rows.length);
  if (alph.has_complement()) {
    add_text_header_cell(row, "Name", "pop_alph_name");
    if (freqs != null) add_text_header_cell(row, "Freq.", "pop_alph_freq");
    if (alph.has_bg()) add_text_header_cell(row, "Bg.", "pop_alph_bg");
    add_text_header_cell(row, "");
    add_text_header_cell(row, "");
    add_text_header_cell(row, "");
    if (alph.has_bg()) add_text_header_cell(row, "Bg.", "pop_alph_bg");
    if (freqs != null) add_text_header_cell(row, "Freq.", "pop_alph_freq");
    add_text_header_cell(row, "Name", "pop_alph_name");
  } else {
    add_text_header_cell(row, "");
    add_text_header_cell(row, "Name", "pop_alph_name");
    if (freqs != null) add_text_header_cell(row, "Freq.", "pop_alph_freq");
    if (alph.has_bg()) add_text_header_cell(row, "Bg.", "pop_alph_bg");
  }
  // add alphabet entries
  tbody = document.createElement("tbody");
  table.appendChild(tbody);
  if (alph.has_complement()) {
    for (i = 0; i < alph.get_size_core(); i++) {
      var c = alph.get_complement(i);
      if (i > c) continue;
      row = tbody.insertRow(tbody.rows.length);
      add_text_cell(row, alph.get_name(i));
      if (freqs != null) add_text_cell(row, "" + freqs[i]);
      if (alph.has_bg()) add_text_cell(row, "" + alph.get_bg_freq(i));
      add_cell(row, colour_symbol(i)); 
      add_text_cell(row, "~");
      add_cell(row, colour_symbol(c)); 
      if (alph.has_bg()) add_text_cell(row, "" + alph.get_bg_freq(c));
      if (freqs != null) add_text_cell(row, "" + freqs[c]);
      add_text_cell(row, alph.get_name(c));
    }
  } else {
    for (i = 0; i < alph.get_size_core(); i++) {
      row = tbody.insertRow(tbody.rows.length);
      add_cell(row, colour_symbol(i)); 
      add_text_cell(row, alph.get_name(i));
      if (freqs != null) add_text_cell(row, "" + freqs[i]);
      if (alph.has_bg()) add_text_cell(row, "" + alph.get_bg_freq(i));
    }
  }
  return table;
}

</script>
    <script>
var memechip_alphabet = new Alphabet(data.alphabet, data.background.freqs);
pre_load_setup();


/*
 * name_from_source
 *
 * Makes a file name more human friendly to read.
 */
function name_from_source(source) {
  if (source == "-") {
    return "-"
  }
  //assume source is a file name
  var file = source.replace(/^.*\/([^\/]+)$/,"$1");
  var noext = file.replace(/\.[^\.]+$/, "");
  return noext.replace(/_/g, " ");
}

/*
 * pre_load_setup
 *
 *  Sets up initial variables which may be
 *  required for the HTML document creation.
 */
function pre_load_setup() {
  "use strict";
  var seq_db, dbs, i, db, progs, prog;
  var db_names = ['sequence_db', 'neg_sequence_db'];
  // get the nams of the sequence databases
  for (i = 0; i < db_names.length; i++) {
    seq_db = data[db_names[i]];
    if (seq_db && !seq_db['name']) {
      seq_db['name'] = name_from_source(seq_db['source']);
    }
  }
  // get the names of the motif databases
  dbs = data['motif_dbs'];
  for (i = 0; i < dbs.length; i++) {
    db = dbs[i];
    if (!db['name']) {
      db['name'] = name_from_source(db['source']);
    }
  }
}

/*
 * page_loaded
 *
 * Called when the page has loaded for the first time.
 */
function page_loaded() {
  post_load_setup();
}

/*
 * page_loaded
 *
 * Called when a cached page is reshown.
 */
function page_shown(e) {
  if (e.persisted) post_load_setup();
}

/*
 * page_loaded
 *
 * Called when a page has been resized
 */
function page_resize() {
  update_scroll_pad();
}

function post_load_setup() {
  update_scroll_pad();
  delayed_process_draw_tasks();
}

//function make_help_button(container, help_topic) {
//  container.appendChild(help_button(help_topic));
//}

function make_description(container, description) {
  "use strict";
  var header, box, paragraphs, p, lines, i, j;
  container.innerHTML = "";
  if (description) {
    header = document.createElement("h2");
    header.className = "mainh pad2";
    header.id = "description";
    header.appendChild(document.createTextNode("Description"));
    container.appendChild(header);
    box = document.createElement("div");
    box.className = "box";
    container.appendChild(box);
    paragraphs = data['description'].split("\n\n");
    for (i = 0; i < paragraphs.length; i++) {
      p = document.createElement("p");
      lines = paragraphs[i].split("\n");
      for (j = 0; j < lines.length; j++) {
        if (j != 0) p.appendChild(document.createElement('br'));
        p.appendChild(document.createTextNode(lines[j]));
      }
      box.appendChild(p);
    }
  }
}

function make_clustered_motifs(container) {
  var groups = data['groups'];
  var motifs = data['motifs'];
  var seq_len = data["sequence_db"]["centrimo_seqlen"];
  var sync_tables = [];
  var i, j;

  container.innerHTML = "";
  toggle_class(container, "more_logos", 1);
  toggle_class(container, "show_known_motifs", data["motif_dbs"].length > 0);
  // check centrimo finished correctly
  var centrimo_ok = false;
  var programs = data["programs"];
  for (i = 0; i < programs.length; i++) {
    if (programs[i]["name"] === "centrimo") {
      centrimo_ok = (programs[i]["status"] == 0);
      break;
    }
  }
  // if centrimo failed then hide it's column
  toggle_class(container, "show_distribution", centrimo_ok);

  // add groups
  for (i = 0; i < groups.length; i++) {
    var alignment = groups[i];
    // calculate the alignment length
    var align_len = 0;
    for (j = 0; j < alignment.length; j++) {
      var align = alignment[j];
      var len = align['offset'] + motifs[align["motif"]]["len"];
      if (align_len < len) align_len = len;
    }
    // create the box to hold group
    var motifbox = document.createElement('div');
    container.appendChild(motifbox);
    motifbox.className = "motifbox";
    // create a table to display this cluster of motifs
    var tbl = document.createElement('table');
    tbl.className = "motifs";
    sync_tables.push(tbl);
    // create the table header
    var thead = document.createElement('thead');
    tbl.appendChild(thead);
    var rhead = thead.insertRow(thead.rows.length);
    add_text_header_cell(rhead, "Motif Found");
    add_text_header_cell(rhead, "Discovery/\u200BEnrichment Program", "pop_source");
    add_text_header_cell(rhead, "E-value", "pop_ev");
    add_text_header_cell(rhead, "Known or Similar Motifs", "pop_tomtom", "col_known_motifs");
    add_text_header_cell(rhead, "Distribution", "pop_centrimo", "col_distribution");
    add_text_header_cell(rhead, "SpaMo & FIMO", "pop_other_prog", "col_other_prog");

    // insert motifs in the table
    var centrimo_list = [];
    var tbody = document.createElement('tbody');
    tbl.appendChild(tbody);
    for (j = 0; j < alignment.length; j++) {
      make_alignment_row(memechip_alphabet, seq_len, motifs, tbody, align_len, alignment[j], j != 0);
      var motif = motifs[alignment[j]["motif"]];
      if (motif["centrimo_sites"]) centrimo_list.push(motif);
    }
    var expandbox = document.createElement('div');
    expandbox.addEventListener("transitionend", logos_end_transition, true);
    expandbox.addEventListener("oTransitionEnd", logos_end_transition, true);
    expandbox.addEventListener("webkitTransitionEnd", logos_end_transition, true);
    expandbox.addEventListener("MSTransitionEnd", logos_end_transition, true);
    expandbox.appendChild(tbl);
    motifbox.appendChild(expandbox);
    if (memechip_alphabet.has_complement()) {
      motifbox.appendChild(make_flip(motifbox));
    }
    if (alignment.length > 1) {
      motifbox.appendChild(make_expand(motifbox, alignment.length, expandbox, tbl));
      var btn = make_compact_btn(motifbox, alignment.length, expandbox, tbl);
      motifbox.appendChild(btn);
      motifbox.compact_btn = btn;
      motifbox.addEventListener("mousemove", position_compact_btn, true);
    }
    if (centrimo_list.length > 1) {
      var group = document.createElement("span");
      group.className = "action";
      var link = document.createElement('a');
      link.appendChild(document.createTextNode("CentriMo Group \u21B7"));
      link.href = centrimo_url(centrimo_list);
      group.appendChild(link);
      group.appendChild(help_button("pop_centrimo_group"));
      motifbox.appendChild(group);
    }
  }
  sync_table_columns(sync_tables);
  toggle_class(container, "more_logos", 0);
}

function make_alignment_row(alphabet, seq_len, motifs, tbody, align_len, align, more) {
  "use strict";
  var i, row, motif, pspm, cell, unaligned, aligned, link, links, matches, match, name;
  var other_prog_list, other_prog, prog;
  // create the row
  row = tbody.insertRow(tbody.rows.length);
  if (more) row.className = "more_logo";
  // get the motif information
  motif = motifs[align["motif"]];
  pspm = new Pspm(motif["pwm"], motif["id"], 0, 0, 
      motif["sites"], motif["evalue"]);
  // Motif Logos
  cell = document.createElement("td");
  if (!more) {// make unaligned logos
    unaligned = document.createElement("span");
    unaligned.className = "unaligned";
    unaligned.appendChild(make_logo(alphabet, pspm, false, 
          0, "normal_logo"));
    if (alphabet.has_complement()) {
      unaligned.appendChild(make_logo(alphabet, pspm, true, 
          0, "flipped_logo"));
    }
    cell.appendChild(unaligned);
  }
  aligned = document.createElement("span");
  aligned.className = "aligned";
  aligned.appendChild(make_logo(alphabet, pspm, align["rc"], 
        align["offset"], "normal_logo"));
  if (alphabet.has_complement()) {
    aligned.appendChild(make_logo(alphabet, pspm, !align["rc"], 
        align_len - (align["offset"] + motif["len"]), "flipped_logo"));
  }
  cell.appendChild(aligned);
  row.appendChild(cell);
  // Motif Source
  link = document.createElement("a");
  links = link;
  if (motif["prog"] == "meme") {
    link.appendChild(document.createTextNode("MEME"));
    link.title = "Click to view the MEME output";
    link.href = "meme_out/meme.html#motif_" + encodeURIComponent(motif["id"]);
  } else if (motif["prog"] == "dreme") {
    link.appendChild(document.createTextNode("DREME"));
    link.title = "Click to view the DREME output";
    link.href = "dreme_out/dreme.html?more=" + encodeURIComponent(motif["id"]);
  } else { // CentriMo
    links = document.createElement("span");
    link.appendChild(document.createTextNode("CentriMo"));
    link.title = "Click to view the CentriMo output";
    link.href = centrimo_url([motif]);
    links.appendChild(link);
    if (motif["db"] == -1) { // from MEME
      links.appendChild(document.createTextNode(" from "));
      link = document.createElement("a");
      link.appendChild(document.createTextNode("MEME"));
      link.title = "Click to view the MEME output";
      link.href = "meme_out/meme.html#motif_" + encodeURIComponent(motif["id"]);
      links.appendChild(link);
    } else if (motif["db"] == -2) { // from DREME
      links.appendChild(document.createTextNode(" from "));
      link = document.createElement("a");
      link.appendChild(document.createTextNode("DREME"));
      link.title = "Click to view the DREME output";
      link.href = "dreme_out/dreme.html?more=" + encodeURIComponent(motif["id"]);
      links.appendChild(link);
    }
  }
  add_cell(row, links);
  // Significance
  add_text_cell(row, motif["sig"]);
  // TOMTOM Summary
  cell = document.createElement("td");
  cell.className = "col_known_motifs";
  if (motif["db"] < 0) { // meme or dreme motif
    matches = motif["tomtom_matches"];
    for (i = 0; i < matches.length && i < 3; i++) {
      match = matches[i];
      name = (match["alt"]? match["alt"] + " (" + match["id"] + ")" : match["id"]);
      if (i != 0) cell.appendChild(document.createElement("br"));
      link = document.createElement("a");
      link.title = "Click to view the Tomtom alignment for this motif.";
      //link.href = motif["prog"] + "_tomtom_out/tomtom.html#match_q_" + 
      //  encodeURIComponent(motif["id"]) + "_t_" + (match["db"] + 1) + "_" + 
      //  encodeURIComponent(match["id"]);
      prog = (motif["db"]==-1) ? "meme" : "dreme";
      //link.href = motif["prog"] + "_tomtom_out/tomtom.html#match_" + 
      link.href = prog + "_tomtom_out/tomtom.html#match_" + 
        encodeURIComponent(motif["idx"]) + "_" + 
        encodeURIComponent(match["idx"]);
      link.appendChild(document.createTextNode(name));
      cell.appendChild(link);
    }
  } else if (typeof motif["url"] === "string") { // database motif
    link = document.createElement("a");
    link.href = motif["url"];
    link.title = "Click to view motif website.";
    name = (motif["alt"]? motif["alt"] + " (" + motif["id"] + ")" : motif["id"]);
    link.appendChild(document.createTextNode(name));
    cell.appendChild(link);
  }
  row.appendChild(cell);
  // CentriMo Summary
  add_cell(row, make_distribution(seq_len, motif), "col_distribution");
  // Other program links
  other_prog_list = document.createElement("ul");
  if (motif["spamo_html"]) {
    link = document.createElement("a");
    link.appendChild(document.createTextNode("Motif Spacing Analysis"));
    link.href = motif["spamo_html"];
    other_prog = document.createElement("li");
    other_prog.appendChild(link);
    other_prog_list.appendChild(other_prog);
  }
  if (motif["fimo_gff"]) {
    link = document.createElement("a");
    link.appendChild(document.createTextNode("Motif Sites in GFF3"));
    link.href = motif["fimo_gff"];
    other_prog = document.createElement("li");
    other_prog.appendChild(link);
    other_prog_list.appendChild(other_prog);
  }

  add_cell(row, other_prog_list, "col_other_prog");
}

function make_program_listing(container) {
  container.innerHTML = "";
  var tbl = document.createElement("table");
  tbl.className = "programs";
  var thead = document.createElement("thead");
  tbl.appendChild(thead);
  row = thead.insertRow(thead.rows.length);
  add_text_header_cell(row, "Command", "", "col_cmd");
  add_text_header_cell(row, "Running Time", "", "col_runtime");
  add_text_header_cell(row, "Status", "", "col_status");
  add_text_header_cell(row, "Outputs", "", "col_outputs");
  var tbody = document.createElement("tbody");
  tbl.appendChild(tbody);
  var progs = data["programs"];
  for (var i = 0; i < progs.length; i++) {
    row = tbody.insertRow(tbody.rows.length);
    var prog = progs[i];
    var cmd_area = document.createElement("div");
    cmd_area.className = "col_cmd";
    var prog_end = prog["cmd"].indexOf(" ");
    if (prog_end == -1) prog_end = prog["cmd"].length;
    var bold_name = document.createElement("b");
    bold_name.appendChild(document.createTextNode(prog["cmd"].substr(0, prog_end)));
    cmd_area.appendChild(bold_name);
    cmd_area.appendChild(document.createTextNode(prog["cmd"].substr(prog_end)));
    add_cell(row, cmd_area, "col_cmd");
    var hours = Math.floor(prog["time"] / 3600);
    var minutes = Math.floor((prog["time"] - 3600 * hours) / 60);
    var seconds = prog["time"] - 3600 * hours - 60 * minutes;
    var time_str;
    if (hours > 0) {
      time_str = "" + hours + "h " + minutes + "m " + seconds.toFixed(2) + "s";
    } else if (minutes > 0) {
      time_str = "" + minutes + "m " + seconds.toFixed(2) + "s";
    } else {
      time_str = "" + seconds.toFixed(2) + "s";
    }
    add_text_cell(row, time_str, "col_runtime");
    var status_text;
    if (prog["oot"]) {
      status_text = "Out of Time";
    } else if (prog["status"] === 0) {
      if (prog["messages_file"]) {
        status_text = "Warnings";
      } else {
        status_text = "Success";
      }
    } else if (prog["status"] === -1) {
      status_text = "Can't Run";
    } else if (prog["status"] & 127 !== 0) {
      status_text = sig_name(prog["status"] & 127);
    } else {
      status_text = "Error " + (prog["status"] >>> 8);
    }
    if (prog["messages_file"]) {
      var link = document.createElement("a");
      link.href = prog["messages_file"];
      link.appendChild(document.createTextNode(status_text));
      add_cell(row, link, "col_status");
    } else {
      add_text_cell(row, status_text, "col_status");
    }
    if (prog["outputs"].length == 0) {
      add_text_cell(row, "", "col_outputs");
    } else {
      var outputs = prog["outputs"];
      var list = document.createElement("ul");
      for (var j = 0; j < outputs.length; j++) {
        var link = document.createElement("a");
        link.href = outputs[j]["file"];
        var name = outputs[j]["file"];
        if (outputs[j]["name"]) {
          name = outputs[j]["name"];
        }
        link.appendChild(document.createTextNode(name));
        var li = document.createElement("li");
        li.appendChild(link);
        list.appendChild(li);
      }
      add_cell(row, list, "col_outputs");
    }
  }
  container.appendChild(tbl);
}

function sig_name(sig_num) {
  "use strict";
  var sig_names = [
    "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGBUS", 
    "SIGFPE", "SIGKILL", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGPIPE", "SIGALRM", 
    "SIGTERM", "SIG16", "SIGCHILD", "SIGCONT", "SIGSTOP", "SIGTSTP", "SIGTTIN", 
    "SIGTTOU", "SIGURG", "SIGXCPU", "SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIG28", 
    "SIGPOLL", "SIG30", "SIGSYS"
  ];
  if ((sig_num - 1) < sig_names.length) {
    return sig_names[sig_num - 1];
  } else {
    return "SIG" + sig_num;
  }
}

function make_sequence_db_listing(id, title) {
  "use strict";
  var container = document.getElementById(id);
  container.innerHTML = "";
  var db = data[id];
  if (db == null) return;
  var header = document.createElement("h4");
  header.textContent = title;
  container.appendChild(header);
  var tbl = document.createElement("table");
  tbl.className = "inputs";
  var thead = document.createElement("thead");
  tbl.appendChild(thead);
  var row;
  row = thead.insertRow(thead.rows.length);
  add_text_header_cell(row, "Database");
  add_text_header_cell(row, "Source");
  add_text_header_cell(row, "Sequence Count");
  var tbody = document.createElement("tbody");
  tbl.appendChild(tbody);
  row = tbody.insertRow(tbody.rows.length);
  var link = document.createElement("a");
  link.href = db["file"];
  link.appendChild(document.createTextNode(db["name"]));
  add_cell(row, link);
  add_text_cell(row, db['source']);
  add_text_cell(row, db['count']);
  container.appendChild(tbl);
}

function make_motif_db_listing(container) {
  "use strict";
  var tbl, thead, tbody, row, i, db, motif_dbs;
  container.innerHTML = "";
  motif_dbs = data['motif_dbs'];
  if (motif_dbs.length == 0) {
    $("motif_dbs_header").style.display = "none";
    return;
  }
  tbl = document.createElement("table");
  tbl.className = "inputs";
  thead = document.createElement("thead");
  tbl.appendChild(thead);
  row = thead.insertRow(thead.rows.length);
  add_text_header_cell(row, "Database");
  add_text_header_cell(row, "Source");
  add_text_header_cell(row, "Motif Count");
  tbody = document.createElement("tbody");
  tbl.appendChild(tbody);
  for (i = 0; i < motif_dbs.length; i++) {
    db = motif_dbs[i];
    row = tbody.insertRow(tbody.rows.length);
    add_text_cell(row, db['name']);
    add_text_cell(row, db['source']);
    add_text_cell(row, db['count']);
  }
  container.appendChild(tbl);
}

var DelayLogoTask = function(logo, canvas) {
  this.logo = logo;
  this.canvas = canvas;
};

DelayLogoTask.prototype.run = function () {
  draw_logo_on_canvas(this.logo, this.canvas, false);
};


function make_logo(alphabet, pspm, rc, offset, className) {
  if (rc) pspm = pspm.copy().reverse_complement(alphabet);
  var logo = new Logo(alphabet, "");
  logo.add_pspm(pspm, offset);
  var canvas = document.createElement('canvas');
  canvas.height = 90;
  canvas.width = 0;
  canvas.className = className;
  size_logo_on_canvas(logo, canvas, false);
  add_draw_task(canvas, new DelayLogoTask(logo, canvas));
  return canvas;
}

var DelayCentrimoPlotTask = function(graph, canvas) {
  this.graph = graph;
  this.canvas = canvas;
};

DelayCentrimoPlotTask.prototype.run = function () {
  this.graph.draw_lines(this.canvas.getContext("2d"), 
      this.canvas.width, this.canvas.height);
};

function make_distribution(seq_len, motif) {
  if (motif["centrimo_sites"]) {
    var canvas = document.createElement("canvas");
    canvas.title = "Click to view the CentriMo output";
    canvas.width = 200;
    canvas.height = 90;
    var rset = new CentrimoRSet(seq_len);
    rset.add("", "", "#000", motif["len"], motif["centrimo_total_sites"], motif["centrimo_sites"]);
    var graph = new CentrimoGraph(rset, triangular_weights(20));
    add_draw_task(canvas, new DelayCentrimoPlotTask(graph, canvas));
    var link = document.createElement("a");
    link.appendChild(canvas);
    link.href = centrimo_url([motif]);
    return link;
  } else {
    var args = data["cmd"];
    var local = "Centrally ";
    var i;
    for (i = 1; i < args.length; i++) {
      if (args[i] === "-centrimo-local") {
        local = "Locally ";
        break;
      }
    }
    var differential = (data['neg_sequence_db']) ? "Differentially " : "";
    return document.createTextNode("Not " + local + differential + "Enriched");
  }
}

function centrimo_url(motifs) {
  var url = "centrimo_out/centrimo.html";
  for (var i = 0; i < motifs.length; i++) {
    var motif = motifs[i];
    var db = motif["db"];
    // If MEME or DREME were run we have to modify the db as it will be 
    // different to the db that CentriMo uses.
    if (db == -1) {
      db = 0; // if meme finds motifs it is always specified first
    } else if (db == -2) {
      // dreme is normally specified second unless meme finds no motifs
      db = (data["motif_count"]["meme"] > 0 ? 1 : 0);
    } else { // program is centrimo
      // other databases always come after meme and dreme databases
      if (data["motif_count"]["meme"] > 0) db++;
      if (data["motif_count"]["dreme"] > 0) db++;
    }
    url += (i == 0 ? "?" : "&");
    url += "show=db" + db + "+" + encodeURIComponent(motif["id"]);
  }
  return url;
}

function make_flip(target) {
  var flip_activator = document.createElement('span');
  flip_activator.className = "action";
  flip_activator.appendChild(document.createTextNode("Reverse Complement \u21C6"));
  flip_activator.flip_target = target;
  flip_activator.onclick = flip_logos;
  return flip_activator;
}

function flip_logos() {
  toggle_class(this.flip_target, "flipped_logos");
}

function show_all(show) {
  "use strict";
  var buttonList, i, button, target, cbtn;
  // find all expansion buttons
  buttonList = document.querySelectorAll("span.more_action");
  for (i = 0; i < buttonList.length; i++) {
    button = buttonList[i];
    target = button.expand_target;
    toggle_class(target, "more_logos", show);
    cbtn = target.compact_btn;
    if (cbtn) cbtn.style.top = "20px";
  }
}

function make_expand(target, nmotifs, grow_box, grow_table) {
  var control = document.createElement('span');
  control.className = "action";
  var activator = document.createElement('span');
  activator.appendChild(document.createTextNode("Show " + (nmotifs - 1) + 
        " More \u21A7"));
  activator.className = "more_action";
  activator.expand_target = target;
  activator.grow_box = grow_box;
  activator.grow_table = grow_table;
  activator.onclick = more_logos;
  control.appendChild(activator);
  var deactivator = document.createElement('span');
  deactivator.appendChild(document.createTextNode("Show  Less \u21A5"));
  deactivator.className = "less_action";
  deactivator.expand_target = target;
  deactivator.grow_box = grow_box;
  deactivator.grow_table = grow_table;
  deactivator.onclick = less_logos;
  control.appendChild(deactivator);
  control.appendChild(help_button("pop_show_clustered"));
  return control;
}

function make_compact_btn(target, nmotifs, grow_box, grow_table) {
  var canvas = document.createElement('canvas');
  canvas.className = "moving_less_action";
  canvas.width = 30;
  canvas.height = 160;
  if (canvas.getContext) {
    var ctx = canvas.getContext('2d');
    draw_compact_btn(ctx, canvas.width, canvas.height);
  }
  canvas.expand_target = target;
  canvas.grow_box = grow_box;
  canvas.grow_table = grow_table;
  canvas.onclick = less_logos;
  return canvas;
}

function draw_compact_btn(ctx, w, h) {
  ctx.save();
  ctx.fillStyle = "black";
  ctx.font = "30px Helvetica";
  ctx.save();
  ctx.textAlign = "center";
  ctx.textBaseline = "top";
  ctx.fillText("\u21A7", w/2 , 0);
  ctx.restore();
  ctx.save();
  ctx.font = "20px Helvetica";
  ctx.translate(w/2, h/2);
  ctx.rotate(-Math.PI / 2);
  ctx.textAlign = "center";
  ctx.textBaseline = "middle";
  ctx.fillText("Show Less", 0, 0);
  ctx.restore();
  ctx.save();
  ctx.textAlign = "center";
  ctx.textBaseline = "alphabetic";
  ctx.fillText("\u21A5", w/2 , h);
  ctx.restore();
  ctx.restore();
}

function position_compact_btn(e) {
  if (!e) var e = window.event;
  var btn = this.compact_btn;
  if (btn) {
    var btn_rect = btn.getBoundingClientRect();
    if (e.clientY > btn_rect.top &&
        e.clientY < (btn_rect.top + btn_rect.height)) {
      return;
    }
    var rect = this.getBoundingClientRect();
    var t = e.clientY - rect.top - (btn.height / 2);
    var tpad = 20;
    var bpad = 50;
    if ((t + btn.height + bpad) > rect.height) t = rect.height - btn.height - bpad;
    if (t < tpad) t = tpad;

    if (typeof btn.update_timer === "undefined") {
      btn.style.top = t + "px";
    }
    if (btn.update_timer) {
      btn.update_top = t;
    } else {
      btn.update_timer = setTimeout(
          function (a_btn) { 
            a_btn.style.top = a_btn.update_top + "px"; 
            btn.update_timer = null;
          }, 500, btn);
    }
  }
}

// from 
// http://stackoverflow.com/questions/7264899/detect-css-transitions-using-javascript-and-without-modernizr
function supportsTransitions() {
    var b = document.body || document.documentElement;
    var s = b.style;
    var p = 'transition';
    if(typeof s[p] == 'string') {return true; }

    // Tests for vendor specific prop
    v = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'],
    p = p.charAt(0).toUpperCase() + p.substr(1);
    for(var i=0; i<v.length; i++) {
      if(typeof s[v[i] + p] == 'string') { return true; }
    }
    return false;
}

function more_logos(e) {
  var will_transition = supportsTransitions();
  if (!more_logos.prev_caller) {
    // stage 1
    toggle_class(this.grow_box, "more_logos", 0);
    if (will_transition) {
      // set size to clip to currently displayed row
      this.grow_box.style.maxHeight = this.grow_table.offsetHeight + "px";
    }
    // need to let the UI update so this works
    more_logos.prev_caller = this;
    setTimeout(more_logos, 0);
    return;
  } else {
    // stage 2
    var me = more_logos.prev_caller;
    if (will_transition) {
      toggle_class(me.expand_target, "inprogress", 1);
      toggle_class(me.grow_box, "motifexpander", 1);
    }
    // show other rows
    toggle_class(me.expand_target, "more_logos", 1);
    if (me.expand_target.compact_btn) {
      me.expand_target.compact_btn.style.top = "20px";
    }
    if (will_transition) {
      // expand size
      me.grow_box.style.maxHeight = me.grow_table.offsetHeight + "px";
    }
    more_logos.prev_caller = null;
  }
}

function less_logos() {
  var will_transition = supportsTransitions();
  if (!less_logos.prev_caller) {
    //stage 1
    toggle_class(this.grow_box, "more_logos", 0);
    if (will_transition) {
      // set size to clip to currently displayed rows
      this.grow_box.style.maxHeight = this.grow_table.offsetHeight + "px";
    }
    // need to let the UI update so this works
    less_logos.prev_caller = this;
    setTimeout(less_logos, 0);
    return;
  } else {
    // stage 2
    var me = less_logos.prev_caller;
    if (will_transition) {
      toggle_class(me.expand_target, "inprogress", 1);
      toggle_class(me.grow_box, "motifexpander", 1);
    }
    toggle_class(me.expand_target, "more_logos", 0);
    if (will_transition) {
      // collapse size
      me.grow_box.style.maxHeight = me.grow_table.offsetHeight + "px";
      toggle_class(me.grow_box, "more_logos", 1);
    } else {
      if (!element_in_viewport(me.expand_target)) {
        me.expand_target.scrollIntoView(true);
      }
    }
    less_logos.prev_caller = null;
  }
}

function logos_end_transition(e) {
  var targ;
  if (!e) var e = window.event;
  if (e.target) targ = e.target;
  else if (e.srcElement) targ = e.srcElement;
  if (targ.nodeType == 3) // defeat Safari bug
    targ = targ.parentNode;

  toggle_class(targ, "motifexpander", 0);
  toggle_class(targ, "more_logos", 0);
  targ.style.maxHeight = "";
  if (!element_in_viewport(targ)) {
    targ.scrollIntoView(true);
  }
  var motifbox_re = /\bmotifbox\b/;
  var p = targ.parentNode;
  while (p) {
    if (motifbox_re.test(p.className)) {
      toggle_class(p, "inprogress", 0);
      break;
    }
    p = p.parentNode;
  }
}


/*
 * sync_table_columns
 *
 * Sets the column widths to be the maximum of the required column widths
 *
 */
function sync_table_columns(tables) {
  var colw = [];
  for (var t = 0; t < tables.length; t++) {
    var table = tables[t];
    for (var r = 0; r < table.rows.length; r++) {
      var row = table.rows[r];
      for (var c = colw.length; c < row.cells.length; c++) {
        colw[c] = 0;
      }
      for (var c = 0; c < row.cells.length; c++) {
        var cell = row.cells[c];
        if (cell.offsetWidth > colw[c]) colw[c] = cell.offsetWidth;
      }
    }
  }
  for (var t = 0; t < tables.length; t++) {
    var table = tables[t];
    for (var r = 0; r < table.rows.length; r++) {
      var row = table.rows[r];
      for (var c = 0; c < row.cells.length; c++) {
        var cell = row.cells[c];
        cell.style.width = colw[c] + "px";
      }
    }
  }
}

</script>
    <style>
table.inputs, table.alpha_bg_table {
  margin-top: 20px;
  border-collapse:collapse;
}
table.inputs * td, table.inputs * th, table.alpha_bg_table * td, table.alpha_bg_table * th {
  padding-left: 15px;
  padding-right: 15px;
  padding-top: 1px;
  padding-bottom: 1px;
}

table.motifs {
  table-layout: fixed;
}
table.motifs * td {
  padding: 1px 5px;
}

div.motifbox {
  border-radius: 10px; 
  border: 2px solid #CCC;
  margin-bottom: 5px;
  padding: 5px;
  padding-left:30px;
  position: relative;
}

div.motifexpander {
  overflow-y: hidden;
  -moz-transition: max-height 1s; 
  -webkit-transition: max-height 1s;  
  -ms-transition: max-height 1s;  
  -o-transition: max-height 1s;  
  transition: max-height 1s;
}

canvas.normal_logo {
  display: block;
}

canvas.flipped_logo {
  display: none;
}

div.flipped_logos * canvas.normal_logo {
  display: none;
}

div.flipped_logos * canvas.flipped_logo {
  display: block;
}

*.action {
  display: inline-block;
  margin-right: 30px;
  cursor: pointer;
  font-size: large;
  -moz-user-select: none;  
  -webkit-user-select: none;  
  -ms-user-select: none;
}
*.action:hover {
  color: #AA2244;
}
*.action a {
  color: inherit;
  text-decoration:none;
}
*.more_logos * span.more_action {
  display: none;
}
*.more_logos * span.less_action {
  display: inline-block;
}
span.more_action {
  display: inline-block;
}
span.less_action {
  display: none;
}
*.more_logo {
  display: none;
}
*.more_logos * tr.more_logo {
  display: table-row;
}

canvas.moving_less_action{
  display: none;
  cursor: pointer;
  position: absolute;
  left: 0px;
  top: 20px;
  -moz-transition: top 1s; 
  -webkit-transition: top 1s;  
  -ms-transition: top 1s;  
  -o-transition: top 1s;  
  transition: top 1s;
}

*.more_logos:hover > canvas.moving_less_action {
  display: block;
}

*.more_logos.inprogress:hover > canvas.moving_less_action {
  display: none;
}

span.aligned {
  display: none;
}
span.unaligned {
  display: inline;
}
*.more_logos * span.aligned {
  display: inline;
}
*.more_logos * span.unaligned {
  display: none;
}

td.col_distribution {
  text-align: center;
}
th.col_distribution, td.col_distribution {
  display: none;
}
*.show_distribution * th.col_distribution, 
  *.show_distribution * td.col_distribution {
  display: table-cell;
}

th.col_known_motifs, td.col_known_motifs {
  display: none;
}

*.show_known_motifs * th.col_known_motifs, 
  *.show_known_motifs * td.col_known_motifs {
  display: table-cell;
}

table.programs {
  table-layout: fixed;
  width: 100%;
}

table.programs * td, table.programs * th {
  padding-top: 5px;
  padding-bottom: 5px;
}

th.col_cmd, td.col_cmd {
}

td.col_cmd {
  vertical-align: top;
}

div.col_cmd {
}

th.col_runtime, td.col_runtime {
  width: 9em;
}

td.col_runtime {
  vertical-align: top;
  text-align: right;
  padding-right: 10px;
}

th.col_status, td.col_status {
  width: 10em;
  vertical-align: top;
}

td.col_status {
  text-align: center;
}

th.col_outputs, td.col_outputs {
  width: 15em;
  vertical-align:top;
}

td.col_outputs ul {
  margin-top: 0px;
  margin-bottom: 0px;
}

p.tar {
  font-size: larger;
}
</style>
    <style>
/* The following is the content of meme.css */
body { background-color:white; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif;}

div.help {
  display: inline-block;
  margin: 0px;
  padding: 0px;
  width: 12px;
  height: 13px;
  cursor: pointer;
  background-image: url(data:image/gif;base64,R0lGODlhDAANAIABANR0AP///yH5BAEAAAEALAAAAAAMAA0AAAIdhI8Xy22MIFgv1DttrrJ7mlGNNo4c+aFg6SQuUAAAOw==);
}

div.help:hover {
  background-image: url(data:image/gif;base64,R0lGODlhDAANAKEAANR0AP///9R0ANR0ACH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEAAAIALAAAAAAMAA0AAAIdDGynCe3PgoxONntvwqz2/z2K2ImjR0KhmSIZUgAAOw==);
}

p.spaced { line-height: 1.8em;}

span.citation { font-family: "Book Antiqua", "Palatino Linotype", serif; color: #004a4d;}

p.pad { padding-left: 30px; padding-top: 5px; padding-bottom: 10px;}

td.jump { font-size: 13px; color: #ffffff; background-color: #00666a;
  font-family: Georgia, "Times New Roman", Times, serif;}

a.jump { margin: 15px 0 0; font-style: normal; font-variant: small-caps;
  font-weight: bolder; font-family: Georgia, "Times New Roman", Times, serif;}

h2.mainh {font-size: 1.5em; font-style: normal; margin: 15px 0 0;
  font-variant: small-caps; font-family: Georgia, "Times New Roman", Times, serif;}

h2.line {border-bottom: 1px solid #CCCCCC; font-size: 1.5em; font-style: normal;
  margin: 15px 0 0; padding-bottom: 3px; font-variant: small-caps;
  font-family: Georgia, "Times New Roman", Times, serif;}

h4 {border-bottom: 1px solid #CCCCCC; font-size: 1.2em; font-style: normal;
  margin: 10px 0 0; padding-bottom: 3px; font-family: Georgia, "Times New Roman", Times, serif;}

h5 {margin: 0px}

a.help { font-size: 9px; font-style: normal; text-transform: uppercase;
  font-family: Georgia, "Times New Roman", Times, serif;}

div.pad { padding-left: 30px; padding-top: 5px; padding-bottom: 10px;}

div.pad1 { margin: 10px 5px;}

div.pad2 { margin: 25px 5px 5px;}
h2.pad2 { padding: 25px 5px 5px;}

div.pad3 { padding: 5px 0px 10px 30px;}

div.box { border: 2px solid #CCCCCC; padding:10px; overflow: hidden;}

div.bar { border-left: 7px solid #00666a; padding:5px; margin-top:25px; }

div.subsection {margin:25px 0px;}

img {border:0px none;}

th.majorth {text-align:left;}
th.minorth {font-weight:normal; text-align:left; width:8em; padding: 3px 0px;}
th.actionth {font-weight:normal; text-align:left;}

.explain h5 {font-size:1em; margin-left: 1em;}

div.doc {margin-left: 2em; margin-bottom: 3em;}

th.trainingset {
  border-bottom: thin dashed black; 
  font-weight:normal; 
  padding:0px 10px;
}
div.pop_content {
  position:absolute;
  z-index:50;
  width:300px;
  padding: 5px;
  background: #E4ECEC;
  font-size: 12px;
  font-family: Arial;
  border-style: double;
  border-width: 3px;
  border-color: #AA2244;
  display:none;
}

div.pop_content > *:first-child {
  margin-top: 0px;
}

div.pop_content h1, div.pop_content h2, div.pop_content h3, div.pop_content h4, 
div.pop_content h5, div.pop_content h6, div.pop_content p {
  margin: 0px;
}

div.pop_content p + h1, div.pop_content p + h2, div.pop_content p + h3, 
div.pop_content p + h4, div.pop_content p + h5, div.pop_content p + h6 {
  margin-top: 5px;
}

div.pop_content p + p {
  margin-top: 5px;
}

div.pop_content > *:last-child {
  margin-bottom: 0px;
}

div.pop_content div.pop_close {
  /* old definition */
  float:right;
  bottom: 0;
}

div.pop_content span.pop_close, div.pop_content span.pop_back {
  display: inline-block;
  border: 2px outset #661429;
  background-color: #CCC;
  padding-left: 1px;
  padding-right: 1px;
  padding-top: 0px;
  padding-bottom: 0px;
  cursor: pointer;
  color: #AA2244; /*#661429;*/
  font-weight: bold;
}

div.pop_content span.pop_close:active, div.pop_content span.pop_back:active {
  border-style: inset;
}

div.pop_content span.pop_close {
  float:right;
  /*border: 2px outset #AA002B;*/
  /*color: #AA2244;*/
}

div.pop_content:not(.nested) .nested_only {
  display: none;
}

div.pop_back_sec {
  margin-bottom: 5px;
}

div.pop_close_sec {
  margin-top: 5px;
}

table.hide_advanced tr.advanced {
  display: none;
}
span.show_more {
  display: none;
}
table.hide_advanced span.show_more {
  display: inline;
}
table.hide_advanced span.show_less {
  display: none;
}


/*****************************************************************************
 * Program logo styling
 ****************************************************************************/
div.prog_logo {
  border-bottom: 0.25em solid #0f5f60;
  height: 4.5em;
  width: 24em;
  display:inline-block;
}
div.prog_logo img {
  float:left;
  width: 4em;
  border-style: none;
  margin-right: 0.2em;
}
div.prog_logo h1, div.prog_logo h1:hover, div.prog_logo h1:active, div.prog_logo h1:visited {
  margin:0;
  padding:0;
  font-family: Arial, Helvetica,  sans-serif;
  font-size: 3.2em;
  line-height: 1em;
  vertical-align: top;
  display: block;
  color: #026666;
  letter-spacing: -0.06em;
  text-shadow: 0.04em 0.06em 0.05em #666;
}
div.prog_logo h2, div.prog_logo h2:hover, div.prog_logo h2:active, div.prog_logo h2:visited {
  display: block;
  margin:0;
  padding:0;
  font-family: Helvetica, sans-serif;
  font-size: 0.9em;
  line-height: 1em;
  letter-spacing: -0.06em;
  color: black;
}

div.big.prog_logo {
  font-size: 18px;
}

</style>
  </head>
  <body onload="page_loaded()" onpageshow="page_shown(event)" 
    onresize="page_resize()" onscroll="delayed_process_draw_tasks()">
    <!-- Help popups -->
    <div class="pop_content" id="pop_alph_name">
      <script>print_doc_para('pop_alph_name', 'alph-name', 'The ');</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    <div class="pop_content" id="pop_alph_bg">
      <script>print_doc_para('pop_alph_bg', 'alph-bg', 'The ');</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    <div class="pop_content" id="pop_summary">
      <script>print_doc("pop_summary", "meme-chip-results-tsv");</script>
      <script>print_doc("pop_summary", "motif-consensus");</script>
      <div style="float:right; bottom:0px;">[ 
	<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    <div class="pop_content" id="pop_combined">
      <script>print_doc("pop_combined", "meme-chip-combined-motifs");</script>
      <div style="float:right; bottom:0px;">[
        <a href="javascript:help_popup()">close</a> ]</div>
    </div>
    <div class="pop_content" id="pop_source">
      <p>This is a link to the motif in the output of the particular motif 
      discovery (e.g., MEME) or motif enrichment (e.g., CentriMo) program that 
      reported it.</p>
      <div style="float:right; bottom:0px;">[ 
        <a href="javascript:help_popup()">close</a> ]</div>
    </div>
    <div class="pop_content" id="pop_ev">
      <p>This is the significance of the motif according to the particular motif
      discovery (e.g., MEME) or motif enrichment (e.g., CentriMo) program that 
      reported it.</p>
      <p>Follow the link under the "Discovery/Enrichment Program" column for 
      more information on how the significance value was derived.</p>
      <div style="float:right; bottom:0px;">[ 
        <a href="javascript:help_popup()">close</a> ]</div>
    </div>
    <div class="pop_content" id="pop_tomtom">
      <p>Motifs reported by a motif discovery program (e.g., MEME) are compared 
      with known motifs in a motif database specified by the user. This column 
      lists the (up to) three most similar motifs. Only known motifs with 
      TOMTOM similarity E-values of less than 1.0 to the discovered motif will 
      be shown here. Clicking any of these links will show the TOMTOM results 
      where all alignments can be viewed.</p>
      <p>Motifs reported by a motif enrichment program (e.g., CentriMo) list the
      motif's name and a link to the motif's entry on the database website if it
      is available.</p>
      <div style="float:right; bottom:0px;">[ 
        <a href="javascript:help_popup()">close</a> ]</div>
    </div>
    <div class="pop_content" id="pop_centrimo">
      <p>This graph shows the distribution of the best matches to the motif in 
      the sequences as found by a CentriMo analysis.</p>
      <p>The vertical line in the center of the graph corresponds to the center
      of the sequences.</p>
      <p>Clicking on a motif's graph will take you to the CentriMo output with 
      that motif selected for graphing.</p>
      <div style="float:right; bottom:0px;">[ 
        <a href="javascript:help_popup()">close</a> ]</div>
    </div>
    <div class="pop_content" id="pop_show_clustered">
      <p>Clicking here will show you all the motifs found by motif discovery or 
      motif enrichment analysis that are significantly similar to the reported 
      motif.</p>  
      <p>The additional motifs are shown aligned with the reported motif, 
      sorted in order of significance of the motif according to the 
      particular motif discovery (e.g., MEME) or motif enrichment 
      (e.g., CentriMo) program that reported it.</p>
      <p>To cluster the motifs MEME ChIP does the following:</p>
      <ol>
        <li>Start with no groups and all significant reported motifs.</li>
        <li>Run TOMTOM with all significant reported motifs to determine 
        pairwise similarity.</li>
        <li>Group Highly Similar Motifs---
        <div style="padding-left: 10px;">
          While ungrouped motifs:
          <div style="padding-left: 10px;">
            Select most significant ungrouped motif.
            <div style="border: 1px solid gray; color: gray">
              This is called the "seed" motif for the group and we will call the
              E-value of its seed motif the group's "significance".
            </div>
            Form a new group from the seed motif and all other motifs that 
            are not yet in a group and who are strongly similar to the seed 
            motif (default: TOMTOM E-value &le; 0.05).
          </div>
        </div>
        </li>
        <li>Merge Groups---
        <div style="padding-left: 10px">
          For each group (most significant to least significant), merge it with 
          any less significant group if all of its motifs are weakly similar to
          the first group's seed motif (default: TOMTOM E-value &le; 0.1).
        </div>
        </li>
      </ol>
      <div style="float:right; bottom:0px;">[ 
        <a href="javascript:help_popup()">close</a> ]</div>
    </div>
    <div class="pop_content" id="pop_centrimo_group">
      <p>Clicking here takes you to the CentriMo motif enrichment analysis with 
      the results for this all the motifs in this group.</p>
      <div style="float:right; bottom:0px;">[ 
        <a href="javascript:help_popup()">close</a> ]</div>
    </div>
    <div class="pop_content" id="pop_other_prog">
      <p>This lists links to related content, which may include:
        <ul>
          <li>Motif Spacing Analysis--SpaMo results using this motif as
		the "primary" motif, and each of the discovered motifs and
		motifs in any motif databases specified to MEME-ChIP as 
		potential "secondary" motifs.  SpaMo reports the secondary
		motifs whose occurrences are enriched at particular distances relative
		to the primary motif's occurrences in the input sequences.
	  <li>Motif Sites in GFF3--FIMO results showing the positions of occurrences
		of this motif in the input sequences in <a href=http://gmod.org/wiki/GFF3>GFF3</a>
		format.  If the input sequences to MEME-ChIP have FASTA headers following
		the UCSC style ("chromosome_name:starting_position-ending_position"),
		and the chromosome names are in UCSC (not ENSEMBL) format,
		the GFF3 output will be suitable for uploading to the UCSC Genome Browser
		as a custom track.
        </ul>
      </p>
      <div style="float:right; bottom:0px;">[ 
        <a href="javascript:help_popup()">close</a> ]</div>
    </div>
    

    <!-- End help popups -->
    <div class="prog_logo big">
      <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHUAAACACAYAAAA1WyYWAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAAd0SU1FB9wLHAIkADZbmgoAACAASURBVHja7L15jLVbdt7129M7nKmqvqpvvPe7t287drsHD1iOUew4HQ+JFStYwUnIhFAEFgkQiwgbHCdxFDMYOhABIjISIEyIB0AgQkByZEJisJJ4aE/pbrvb7jt/c41neqc98cfe5z312d3tFmnJ6OoeqaSqU+8577D3XutZz3rW2iKEwLuvd85LCIF89zG8817vDuq7g/ru691Bfff17qC++3p3UN99fZaXts5jtHruzeg8QgpA7HByet/7/KcEmd/LIZFQEYJN0yRGAIIHqTUQ9vMnmvTn86ckRhAi/Kb5FsO1SxA+vRHyd0kBwqbfvdx/j87XHUW+DocUEVQ+aZQQIgj9/Pl3U1yM7+7fiNfjht3/fH7D/4YPSqINCC1B9PvvipIQIlLtvswAJcGDoN8/RwS4CKq6/oSuXU6+Hrm/qOBAKgEC9M/99D+KwTvm89l4wMXFkrrU1PVkvGPrLF2bTmwKQ1EURARd26TbCp7ZvGAyMWy2WwA2azg+qagnBUqVAJydbVkuG6QElR9yjALrHFWVHnKIHq0L+n5IDx84WMwwBpwdWC8HAOpaMZ+X9NbSt+nBtn1gOi+RSuJc+myz7ahKmNRlPp9ku+lwLqJNmYdD4Hy6T6NNvk9BjAFrPT5PaClAaUWMEWvTjDs4hOm0Qimd73vLahk5uqG5cTzJ19VydWnxHso63bfWFUOvWF6umE3To755ckgIsFxu2azShC0KQ8AT8yS1Q0RK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AHUugOBGR964mSsg12n+eqKnrRVSwDg1VUGtD7TTeG7w3WBRoKJ2idAovM4JIsC5G3DaAI8H6JCqs6vgurcCHDGtN+3SJAFiDsAnKa5TXkUXgFT7o9o2MC8BisBjqoKOCXwChMoTKsE7hvSZRtLuILTVa9LBONyj/JgoOASEcQrio3SgEtdQUQca3CxijcX4hfyCVpLZ1VEhr3sKkBJFGswqlUUpjvcH6jL977wfxIZZcj5zY5R3v+QBCdkEoTmxtt0GT/nHo8c/jlSQJr/jTqIf86j//M3pdzetf+2fUteXNf/06dkcLsS5hqwKp9cnAmLhvCk4yq5kHAeFOvbtTwdCnYmh8CC1s8RTsTQPEvuPfnUQNbnk94nuIV82vFfygn00TcJ3qby7kHX9HaL5TnMK/CSG0VmeLQpw8VfPu5M8K4Q5jxILwIsIiET4V8LRIvgHv7GLs5Em+Zk165K1t5q1BlJQlJs0QQiO8d+3PPnkIIrn0pEkUYjFpPsTBE/IU8Y0YRXPSRIomqj55mEUzeOGkwVtcN7/Ce98M5MJMB0Tz2ScZ7Ah50r86ecpDGzm3MJSTlMbihC506uPvEd9nkYZTF02IBK95sX4hCnvqGAbvTlqUsdY8d05c/DPxPYyWTv3e4JuFdtJ13rpTH0YEtq4xSYYIPyKftB+//v95/R8QRR+pt7kfewAAAABJRU5ErkJggg==" alt="MEME-ChIP Logo" id="title_icon">
      <h1>MEME-ChIP</h1>
      <h2>Motif Analysis of Large Nucleotide Datasets</h2>
    </div>
    <p>
      For further information on how to interpret these results please access
      <a href="http://meme-suite.org/doc/meme-chip-output-format.html">http://meme-suite.org/doc/meme-chip-output-format.html</a>.<br>
      To get a copy of the MEME software please access
      <a href="http://meme-suite.org">http://meme-suite.org</a>.
    </p>
    <p>
      If you use MEME-ChIP in your research, please cite the following paper:<br />
      <span class="citation">
        Philip Machanick and Timothy L. Bailey, "MEME-ChIP: motif analysis of large DNA datasets",
        <i>Bioinformatics</i>, <b>27</b>12, 1696-1697, 2011.
        <a href="http://bioinformatics.oxfordjournals.org/content/27/12/1696.full">[full text]</a>
      </span>
    </p>
    <!-- navigation -->
    <div class="pad2">
      <a class="jump" href="#data_sec">Motifs</a>
      &nbsp;&nbsp;|&nbsp;&nbsp;
      <a class="jump" href="#programs_sec">Programs</a>
      &nbsp;&nbsp;|&nbsp;&nbsp;
      <a class="jump" href="#input_sec">Input Files</a>
      &nbsp;&nbsp;|&nbsp;&nbsp;
      <a class="jump" href="#info_sec">Program information</a>
      &nbsp;&nbsp;|&nbsp;&nbsp;
      <a class="jump" href="summary.tsv">Summary in TSV Format</a>&nbsp;<span id="summary_help"></span>&nbsp;<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAQCAMAAAAyEe/dAAAACVBMVEX//wAAAAD////s2cV/AAAAdUlEQVQYlXVRBxLAIAhL+P+jC2HZhXcBZEWEldDsZcLIcAhHWWnK8SDcWQhMFUHdAQ1CqQ5+CWPmlHojl+nCJNRtzu4qRc3IUzmTVpXYK0nox0z0PI1stgchdK7lEv7ekhvalw8WW547Gyzedt/2/gLx8WXjXF/1AYFriNAWAAAAAElFTkSuQmCC" alt="NEW" id="new_1">
      &nbsp;&nbsp;|&nbsp;&nbsp;
      <a class="jump" href="combined.meme">Motifs in MEME Text Format</a>&nbsp;<span id="combined_help"></span>&nbsp;<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAQCAMAAAAyEe/dAAAACVBMVEX//wAAAAD////s2cV/AAAAdUlEQVQYlXVRBxLAIAhL+P+jC2HZhXcBZEWEldDsZcLIcAhHWWnK8SDcWQhMFUHdAQ1CqQ5+CWPmlHojl+nCJNRtzu4qRc3IUzmTVpXYK0nox0z0PI1stgchdK7lEv7ekhvalw8WW547Gyzedt/2/gLx8WXjXF/1AYFriNAWAAAAAElFTkSuQmCC" alt="NEW" id="new_2">
      <script> 
        make_help_button($("summary_help"), "pop_summary"); 
        make_help_button($("combined_help"), "pop_combined"); 
      </script>
    </div>
    <!-- alert the user when their browser is not up to the task -->
    <noscript><h1 style="color:red">Javascript is required to view these results!</h1></noscript>
    <h1 id="html5_warning" style="color:red; display:none;">Your browser does not support canvas!</h1>
    <script>if (!window.HTMLCanvasElement) $("html5_warning").style.display = "block";</script>
    <!-- write out the job description -->
    <span id="ins_desc"></span>
    <script>make_description($("ins_desc"), data["description"]);</script>
    <!-- write out clustered motifs -->
    <h2 class="mainh pad2" id="data_sec">Motifs</h2>
    <div class="box">
      <p><b>The significant motifs 
      (E-value &le; <span id="ins_filter_thresh"></span>)
      found by the programs MEME, DREME and CentriMo; 
      clustered by similarity and ordered by E-value.</b></p>
      <script>$("ins_filter_thresh").innerHTML = data["filter_thresh"]; </script>
      <div class="motifbox">
        <span class="action" onclick="show_all(true)">Expand All Clusters</span>
        <span class="action" onclick="show_all(false)">Collapse All Clusters</span>
      </div>
      <div id="logos"></div>
      <script>make_clustered_motifs($("logos"));</script>
    </div>
    <!-- write out a list of all programs run -->
    <h2 class="mainh pad2" id="programs_sec">Programs</h2>
    <div class="box" id="program_listing"></div>
    <script>make_program_listing($("program_listing"));</script>
    <!-- write out input files -->
    <h2 id="input_sec" class="mainh pad2">Input Files</h2>
    <div id="input_files" class="box">
      <h4>Alphabet</h4>
      <span id="bg_source"></span>
      <div class="pad" id="alpha_bg"></div>
      <script>
        $("bg_source").appendChild(make_background_source("Background source", data.background['source']));
        $("alpha_bg").appendChild(make_alpha_bg_table(memechip_alphabet));
      </script>
      <div id="sequence_db"></div>
      <script>make_sequence_db_listing('sequence_db', "Primary Sequences");</script>
      <div id="neg_sequence_db"></div>
      <script>make_sequence_db_listing('neg_sequence_db', "Control Sequences");</script>
      <h4 id="motif_dbs_header">Motifs</h4>
      <div id="motif_dbs"></div>
      <script>make_motif_db_listing($("motif_dbs"));</script>
    </div>
    <!-- list information on this program -->
    <div id="info_sec" class="bar">
      <div class="subsection">
        <h5 id="version">MEME-ChIP version</h5>
        <span id="ins_version"></span> 
        (Release date: <span id="ins_release"></span>)<br>
      </div>
      <script>
        $("ins_version").innerHTML = data["version"];
        $("ins_release").innerHTML = data["release"];
      </script>
      <div class="subsection">
        <h5 id="reference">Reference</h5>
        <span class="citation">
        Philip Machanick and Timothy L. Bailey, "MEME-ChIP: motif analysis of large DNA datasets",
        <i>Bioinformatics</i>, <b>27</b>12, 1696-1697, 2011.
        </span>
        <div class="subsection">
          <h5 id="command">Command line summary</h5>
          <textarea id="cmd" rows="5" style="width:100%;" readonly="readonly">
          </textarea>
          <script>$("cmd").value = data["cmd"].join(" ");</script>
        </div>
      </div>
    </div>
    <div id="scrollpad"></div>
  </body>
</html>
